This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: bug in <sys/un.h>
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 30 May 2013 22:03:44 +0200
- Subject: Re: bug in <sys/un.h>
- References: <51A78E70 dot 1010600 at redhat dot com>
- Reply-to: cygwin at cygwin dot com
On May 30 11:37, Eric Blake wrote:
> STC - this program does nothing useful when executed; it merely exists
> to show a compilation problem extracted from a larger program:
>
> $ cat foo.c
> #ifdef WORKAROUND
> # include <sys/socket.h>
> #endif
> #include <sys/un.h>
> #include <sys/socket.h>
> int main(void) {
> const struct msghdr msg;
> return sendmsg(0, &msg, 0);
> }
> $ gcc -o foo -Wall foo.c
> foo.c: In function 'main':
> foo.c:9:5: warning: passing argument 2 of 'sendmsg' from incompatible
> pointer type
> /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *'
> but argument is of type 'const struct msghdr *'
> $ gcc -o foo -Wall foo.c -DWORKAROUND
> $
>
> Gcc has a less-than-stellar error message (expect type X but have type
> X); it could do a better job about pointing out that it is complaining
> about two different 'type X' declarations, and where they come from.
> But the root cause is that if <sys/un.h> is included first, then the use
> of 'struct msghdr' applied in the declaration of sendmsg() is somehow
> scoped incorrectly (local to the declaration rather than the global
> type), so that the compiler really is complaining about two different
> incompatible 'struct msghdr' layouts. I'm not quite sure what the fix
> should be, [...]
Try this:
Index: cygwin/if.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/if.h,v
retrieving revision 1.11
diff -u -p -r1.11 if.h
--- cygwin/if.h 21 Jan 2013 04:38:30 -0000 1.11
+++ cygwin/if.h 30 May 2013 20:02:56 -0000
@@ -16,7 +16,7 @@ extern "C" {
#endif /* __cplusplus */
#include <sys/types.h>
-#include <sys/socket.h>
+#include <cygwin/socket.h>
/* Standard interface flags. */
#define IFF_UP 0x1 /* interface is up */
It resolves a circular dependency problem in the header files.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--
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