Predefined macros in C/C++ that tell you what language features are available.

These are the predefined macros that C/C++ compilers define to tell you what language features are available. There are also predefined macros in C/C++ that tell you the compiler, predefined macros in C/C++ that tell you the target processor and predefined macros in C/C++ that tell you what language features are available.

These are most often used in library header files.

Feature Macros for each compiler
OpenWatcom MSVC++ IBM VAC++/ILEC++ DigitalMars GCC
Feature OpenWatcom MSVC++ IBM VAC++/ILEC++ DigitalMars GCC
Macros for each compiler
The run-time library is in a DLL (so standard library headers have to mark function declarations as imported) __SW_BR is 1 _DLL is 1 __IMPORTLIB__ is 1 _DLL is 1 (nothing)
Multiple threading support is desired in the run-time library. __SW_BM is 1 and _MT is 1 _MT is 1 __MULTI__ is 1 _MD is 1 _REENTRANT is 1
Exceptions are enabled. __CPPUNWIND is 1 _CPPUNWIND is 1 (nothing) _CPPUNWIND is 1 __EXCEPTIONS__ is 1
Run-time type information (and thus dynamic casting) is enabled. __CPPRTTI is 1 _CPPRTTI is 1 (nothing) (nothing) __GXX_RTTI is 1
char is signed. __SW_J is 1 and __CHAR_SIGNED__ is 1 (nothing) _CHAR_SIGNED is 1 and __CHAR_SIGNED__ is 1 (nothing) (nothing)
char is unsigned. (nothing) __CHAR_UNSIGNED__ is 1 _CHAR_UNSIGNED is 1 and __CHAR_UNSIGNED__ is 1 _CHAR_UNSIGNED is 1 __CHAR_UNSIGNED__ is 1
wchar_t is signed. (nothing) (nothing) (nothing) (nothing) (nothing)
wchar_t is unsigned. (nothing) (nothing) (nothing) (nothing) __WCHAR_UNSIGNED__ is 1
Language extensions are available (and so can be safely used in headers). (nothing) _MSC_EXTENSIONS is 1 __EXTENDED__ is 1 (nothing) (nothing)
Language extensions are unavailable (and so cannot be safely used in headers). NO_EXT_KEYS is 1 (nothing) __ANSI__ is 1 (nothing) __STRICT_ANSI__ is 1
Library headers may declare inline functions. __SW_OI is 1 and __INLINE_FUNCTIONS__ is 1 (nothing) (nothing) (nothing) (nothing)
Library headers may not declare inline functions. (nothing) (nothing) (nothing) (nothing) __NO_INLINE__ is 1
Library headers may use compiler intrinsics. __SW_OM is 1 (nothing) (nothing) (nothing) (nothing)
Optimization for space, rather than time, is requested. __SW_OS is 1 (nothing) (nothing) (nothing) __OPTIMIZE_SIZE__ is 1

© Copyright 2012 Jonathan de Boyne Pollard. "Moral" rights asserted.
Permission is hereby granted to copy and to distribute this web page in its original, unmodified form as long as its last modification datestamp information is preserved.