Re: Can't get includes untangled
On 10/01/2012 19:25, Larry Hall (Cygwin) wrote: On 1/10/2012 2:17 PM, Jarome wrote: When I make my Windows 7 cygwin project, I keep getting In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../ include/w32api/windows.h:98:0, from src/tkfPusher.c:23: /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/ winsock2.h:103:2: warning: #warning fd_set and associated macros have been defined in sys/types. This may cause runtime problems with W32 sockets Everything works in MinGW. Don't include windows files for Cygwin. Think of Cygwin as a UNIX/Linux environment. Anything you wouldn't include there shouldn't be included when building for Cygwin. That's a simple rule to follow that will avoid some problems, but I thought mixed-mode coding wasn't actually prohibited and we don't actually go out of our way to break it - hence the existence of __USE_W32_SOCKETS in the first place, no? To Jarome: I tried adding the #define __USE_W32_SOCKETS to try and fix this because if defined, it should ignore the fd things in types.h, but no success. The problem is that you're not defining it early enough: #define GPC_CYGWIN #define GPC_WIN #include stdio.h #include errno.h #include dirent.h // This includes sys/types.h Yes, it does, so __USE_W32_SOCKETS should already have been defined by that point or it's too late; both winsock2.h *and* sys/types.h have to be #included while it is already in effect (they both contain #ifdefs that test it). And in fact, stdio.h also indirectly include sys/types.h, so the simple answer is just to define __USE_W32_SOCKETS right at the top alongside the other defines before you even include the first file. cheers, DaveK -- 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
Can't get includes untangled
When I make my Windows 7 cygwin project, I keep getting In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../ include/w32api/windows.h:98:0, from src/tkfPusher.c:23: /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/ winsock2.h:103:2: warning: #warning fd_set and associated macros have been defined in sys/types. This may cause runtime problems with W32 sockets Everything works in MinGW. I tried adding the #define __USE_W32_SOCKETS to try and fix this because if defined, it should ignore the fd things in types.h, but no success. So how do I untangle the includes for Cygwin? The code is: #define GPC_CYGWIN #define GPC_WIN #include stdio.h #include errno.h #include dirent.h // This includes sys/types.h #ifdef GPC_WIN #define __USE_W32_SOCKETS #include windows.h #include process.h #include time.h #ifdef GPC_CYGWIN // winsoch2.h should be included by windows.h if __USE_W32_SOCKETS is defined //#include w32api/winsock2.h #include w32api/winbase.h #include string.h #endif #ifdef GPC_MINGW #include winsock2.h #include winbase.h #include string.h #endif #endif Thanks for the help, Jim -- 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
Re: Can't get includes untangled
On 1/10/2012 2:17 PM, Jarome wrote: When I make my Windows 7 cygwin project, I keep getting In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../ include/w32api/windows.h:98:0, from src/tkfPusher.c:23: /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/ winsock2.h:103:2: warning: #warning fd_set and associated macros have been defined in sys/types. This may cause runtime problems with W32 sockets Everything works in MinGW. Don't include windows files for Cygwin. Think of Cygwin as a UNIX/Linux environment. Anything you wouldn't include there shouldn't be included when building for Cygwin. -- Larry _ A: Yes. Q: Are you sure? A: Because it reverses the logical flow of conversation. Q: Why is top posting annoying in email? -- 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