Determining whether compilation is possible on Windows or another system

I am currently developing a cross-platform C application . Is there any compiler macro that is only defined at compile time on Windows, so I can #ifdefspecify some specific Windows * include?

A typical example is the choice between WinSock and Berkeley socket 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 I'm looking for something like a _WINDOWS macro .

+5
source share
3 answers

Best used

_WIN32

, 32- 64- Windows Visual ++. , Windows ( Intel ++ , MinGW gcc).

+10

_WIN32.

:

+3
_WIN32  

Win32 Win64. .

_WIN64  

Win64.

: ANSI C Microsoft ++.

+2

All Articles