2007-07-12

Useful GCC Macros

You should always prefer to use more general tests than less general ones, since that way your program is more likely to work on future hardware and other operating systems. Most of these defines are specific to GCC. Check for them with #if defined(macro).

Compiler
__GNUC__You're compiling with GCC
__APPLE_CC__You're compiling with Apple's own GCC
Operating System
__APPLE__You're compiling for Apple hardware
linuxYou're compiling for Linux
_WIN32You're compiling for 32-bit Windows
Hardware (General)
__LP64__(Apple-only) You're compiling for a 64-bit machine (Longs and Pointers are 64-bit)
__BIG_ENDIAN__You're compiling for a big-endian machine
__LITTLE_ENDIAN__ You're compiling for a little-endian machine
Hardware (Specific)
__ppc__You're compiling for a 32-bit PowerPC
__i386__You're compiling for a 32-bit Intel
__ppc64__You're compiling for a 64-bit PowerPC
__x86_64__You're compiling for a 64-bit Intel

0 comments: