When compiling a C / C ++ program under Windows using Visual Studio (or a compiler that tries to be compatible) there is a predefined macro _WIN32 (Source: http://msdn.microsoft.com/en-us/library/b0084kay.aspx ), which you can use for # -dedef-s for the platform.
I am looking for an analogue under Linux: a macro that tells me that I am compiling for Linux / OS, which claims to be (more or less) POSIX compatible.
So, I looked through the gcc documentation and found this: http://gcc.gnu.org/onlinedocs/cpp/System_002dspecific-Predefined-Macros.html
For my program, the following macros (gcc 4.4.5 - Ubuntu 10.10) looked promising (I hope that I have not lost an important macro):
#define __USE_BSD 1 #define __unix__ 1 #define __linux 1 #define __unix 1 #define __linux__ 1 #define _POSIX_SOURCE 1 #define __STDC_HOSTED__ 1 #define __STDC_IEC_559__ 1 #define __gnu_linux__ 1 #define __USE_SVID 1 #define __USE_XOPEN2K 1 #define __USE_POSIX199506 1 #define _G_USING_THUNKS 1 #define __USE_XOPEN2K8 1 #define _BSD_SOURCE 1 #define unix 1 #define linux 1 #define __USE_POSIX 1 #define __USE_POSIX199309 1 #define __SSP__ 1 #define _SVID_SOURCE 1 #define _G_HAVE_SYS_CDEFS 1 #define __USE_POSIX_IMPLICITLY 1
Where can I find detailed documentation on them - regarding the Windows macros mentioned above?
In addition, I would be interested in macros that are usually defined for other POSIX compatible operating systems: * BSD, etc.
Nubok source share