This is the mail archive of the
cygwin
mailing list for the Cygwin project.
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