Determining whether compiling on Windows or other system

Posted by NumberFour on Stack Overflow See other posts from Stack Overflow or by NumberFour
Published on 2010-04-05T15:18:45Z Indexed on 2010/04/05 15:23 UTC
Read the original article Hit count: 280

Hi,

Im currently developing a cross-platform C application. Is there any compiler macro which is defined only during compilation on Windows, so I can #ifdef some Windows specific #includes?

Typical example is selecting between WinSock and Berkeley sockets headers:

#ifdef _WINDOWS
   #include <winsock.h>    
#else
   #include <sys/socket.h>
   #include <netinet/in.h>
   #include <sys/un.h>
   #include <arpa/inet.h>
   #include <netdb.h>
#endif

So the thing Im looking for is something like that _WINDOWS macro. Thanks for any tips.

© Stack Overflow or respective owner

Related posts about c

    Related posts about preprocessor-directives