Tuesday, October 30, 2012

Predefined Macros

There are predefined macros that are used by most compilers, you can find the list [here]. GCC compiler predefined macros can be found [here].

http://sourceforge.net/p/predef/wiki/OperatingSystems/

http://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html


#ifdef _WIN64
   //define something for Windows (64-bit)
#elif _WIN32
   //define something for Windows (32-bit)
#elif __APPLE__
    #include "TargetConditionals.h"
    #if TARGET_OS_IPHONE    
         // iOS device
    #elif TARGET_IPHONE_SIMULATOR
        // iOS Simulator
    #elif TARGET_OS_MAC
        // Other kinds of Mac OS
    #else
        // Unsupported platform
    #endif
#elif __linux
    // linux
#elif __unix // all unices not caught above
    // Unix
#elif __posix
    // POSIX
#endif

No comments: