This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99


Hi,

rev 1.101 of winbase.h from 2010.08.24 introduces an anonymous structure and union to the OVERLAPPED definition [1].

Unfortunately, this only works when compiling with -std=gnu99 (default), but not with -std=c99.

The following demonstrates the problem:

----------------------------------------------------------------------
$ cat > overlapped_test.c << _EOL
#include <stdio.h>
#include <windows.h> 	/* includes winbase.h */
int main(int argc, char** argv) {
    OVERLAPPED ov;

    printf("size of OVERLAPPED: %d\n", sizeof(ov));
    return 0;
}
_EOL

$ gcc -std=gnu99 -o overlapped_test overlapped_test.c

$ ./overlapped_test.exe
size of OVERLAPPED: 20

$ gcc -std=c99 -o overlapped_test overlapped_test.c

$ ./overlapped_test.exe
size of OVERLAPPED: 12
----------------------------------------------------------------------

The main issue appears to be that, since C99 does not support GNU99 anonymous structs/unions, it simply ignores them. But this wreaks havoc on any source compiled in c99 mode that exchanges an OVERLAPPED with the OS. This usually results in an "invalid handle error" from Windows.

Any application compiled in C99 mode and using OVERLAPPED is therefore expected to break, and we have seen that issue after people upgraded their cygwin installation and tried recompiling libusb [2]. Our current workaround is to switch to gnu99, but with a source that is common to both MSVC, MinGW and cygwin, GNU extensions is something we would like to avoid. Also, the problem seems to have now spread to the latest MinGW32 now (are they reusing cygwin's winbase.h?).

We would appreciate if you could look into this and ensure that winbase.h is C99 compliant.

Regards,

/Pete


[1] http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/winbase.h.diff?r1=1.100&r2=1.101&cvsroot=src&f=h
[2] http://git.libusb.org/?p=libusb-pbatard.git;a=commit;h=fb33bf26916dae3a443c9d831d5f9985f58bcc6b;js=1


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]