public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99
@ 2011-03-03 16:45 Pete Batard
  2011-03-03 17:37 ` Christopher Faylor
  0 siblings, 1 reply; 3+ messages in thread
From: Pete Batard @ 2011-03-03 16:45 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99
  2011-03-03 16:45 w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99 Pete Batard
@ 2011-03-03 17:37 ` Christopher Faylor
  2011-03-03 17:55   ` Pete Batard
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Faylor @ 2011-03-03 17:37 UTC (permalink / raw)
  To: cygwin

On Thu, Mar 03, 2011 at 04:45:50PM +0000, Pete Batard wrote:
>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?).

It's the other way around.  Cygwin's winbase.h comes from MinGW.  If
there is an issue you need to take it up with the MingW folks.

OTOH, for Cygwin programs you shouldn't be using winbase.h at all.

cgf

--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99
  2011-03-03 17:37 ` Christopher Faylor
@ 2011-03-03 17:55   ` Pete Batard
  0 siblings, 0 replies; 3+ messages in thread
From: Pete Batard @ 2011-03-03 17:55 UTC (permalink / raw)
  To: cygwin

On 2011.03.03 17:37, Christopher Faylor wrote:
> It's the other way around.  Cygwin's winbase.h comes from MinGW.  If
> there is an issue you need to take it up with the MingW folks.

Ah OK - will do then.

> OTOH, for Cygwin programs you shouldn't be using winbase.h at all.

For pure cygwin yes, but we wanted a common abstracted polling for 
asynchronous transfers on Windows platforms, since poll() it's not 
available in MSVC, and the only option then is to use an OVERLAPPED.

Anyway, thanks for the reply.

Regards,

/Pete

--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-03 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-03 16:45 w32api/include/winbase.h rev. 1.101, OVERLAPPED and -std=c99 Pete Batard
2011-03-03 17:37 ` Christopher Faylor
2011-03-03 17:55   ` Pete Batard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).