Appendixes


Appendix A. Predefined Macros

Predefined macros fall into several categories: those related to language features, those related to the compiler, and those related to the Linux platform.

For information about macros related to language features, including those mandated by the language specification, see "Preprocessor Directives" in XL C/C++ Language Reference.


Macros indicating the XL compilers

Predefined macros related to the XL compiler are always defined.

Predefined macro name Description
__IBMC__ C only. Indicates the level of the XL C compiler as an integer constant representing version, release, and modification number.
__IBMCPP__ C++ only. Indicates the level of the XL C++ compiler as an integer constant representing version, release, and modification number.
__xlc__ C only. Indicates the level of the XL C compiler as a string displaying the version, release, modification, and fix level.
__xlC__ C++ only. Indicates the level of the XL C++ compiler as a three-digit hexadecimal constant, representing version, release, and modification number. Using the XL C compiler also automatically defines this macro.

Macros related to the Linux platform

The following predefined macros are provided to facilitate porting applications between platforms.

Predefined Macro Name Description
_ARCH_PPC Defined to 1 if the processor architecture is PowerPC.
_ARCH_PPC64 Defined to 1 if the processor architecture is PowerPC.
__BASE_FILE__ Defined to the fully qualified filename of the primary source file.
_BIG_ENDIAN Defined to 1.
__BIG_ENDIAN__ Defined to 1.
_CALL_SYSV Defined to 1.
__CHAR_UNSIGNED__ Defined to 1 if the option -qchars=unsigned or #pragma chars(unsigned) is in effect. This macro is undefined if the option -qchars=signed or #pragma chars(signed) is in effect.
__ELF__ Defined to 1 on this platform to indicate the ELF object model is in effect.
__EXCEPTIONS Applies to C++ Defined to 1 if the -qeh option is in effect. Otherwise it is not defined.
__GXX_WEAK__ Undefined for C. For C++, this macro is defined to 0 for g++ V3.3 or 1 for g++ V3.5.
__HOS_LINUX__ Defined to 1 if the host operating system is Linux. Otherwise it is not defined.
__linux Defined to 1.
__linux__ Defined to 1.
__OPTIMIZE__ Defined to 2 for optimization level -O or -O2, or to 3 for optimization level -O3 or higher.
__OPTIMIZE_SIZE__ Defined to 1 if the options -qcompact and -O are set. Otherwise it is not defined.
__powerpc Defined to 1.
__powerpc__ Defined to 1.
__powerpc64__ Defined to 1 when compiling in 64-bit mode. Otherwise it is not defined.
__PPC Defined to 1.
__PPC__ Defined to 1.
__PPC64__ Defined to 1 when compiling in 64-bit mode. Otherwise it is not defined.
__SIZE_TYPE__ Defined to the underlying type of size_t on this platform. On this platform, the macro is defined as long unsigned int.In 32-bit mode, the macro is defined as unsigned int. In 64-bit mode, the macro is defined as long int. The compile mode is controlled by the -q32 and -q64 options.
__TOS_LINUX__ Defined to 1 if the target operating system is Linux. Otherwise it is not defined.
__unix Defined to 1 on all UNIX-like platforms. Otherwise it is not defined.
__unix__ Defined to 1 on all UNIX-like platforms. Otherwise it is not defined.

IBM Copyright 2003