Macros to identify the XL C/C++ compiler

Most of the macros related to the XL C/C++ compiler are predefined and protected, which means that the compiler will issue a warning if you try to undefine or redefine them. You can use these macros to distinguish code consumed by XL C/C++ from code consumed by other compilers in your programs.

Two categories of invocation commands are available in IBM® XL C/C++ for AIX® 16.1. For detailed information, see Invoking the compiler. These two categories of invocation commands have different predefined macros:
  • For xlc/xlC and equivalent special invocations, see Table 1.
  • For xlclang/xlclang++, see Table 2.

XL-based front end beginsYou can use the -qshowmacros=pre -E compiler options to view the values of the predefined macros. XL-based front end ends

Clang-based front end beginsYou can use -qshowmacros -E on an empty source file to view the values of the predefined macros.Clang-based front end ends

Table 1. Compiler-related predefined macros for xlc/xlC and equivalent special invocations
Predefined macro name Description Predefined value
C only__IBMC__ Indicates the level of the XL C compiler. An integer in format VRM, where:
V
Represents the version number
R
Represents the release number
M
Represents the modification number
C++ only__IBMCPP__ Indicates the level of the XL C++ compiler. An integer in format VRM, where:
V
Represents the version number
R
Represents the release number
M
Represents the modification number
C only.__xlc__ Indicates the level of the XL C compiler. A string in format V.R.M.F, where:
V
Represents the version number
R
Represents the release number
M
Represents the modification number
F
Represents the fix level
__xlC__ Indicates the VR level of the XL C and XL C++ compilers in hexadecimal format. A 4-digit hexadecimal integer in format 0xVVRR, where:
V
Represents the version number
R
Represents the release number
__xlC_ver__ Indicates the MF level of the XL C and XL C++ compilers in hexadecimal format. An 8-digit hexadecimal integer in format 0x0000MMFF, where:
M
Represents the modification number
F
Represents the fix level

For example, in PTF 3, the value of the macro is 0x00000003.

Table 2. Compiler-related predefined macros for xlclang/xlclang++
Predefined macro name Description Predefined value
__ibmxl__ Indicates the XL C/C++ compiler is being used. 1
__ibmxl_vrm__ Indicates the VRM level of the XL C/C++ compiler using a single integer for sorting purposes. A hexadecimal integer whose value is as follows:
(((__ibmxl_version__) << 24) | \
 ((__ibmxl_release__) << 16) | \ 
 ((__ibmxl_modification__) << 8) \
)
__ibmxl_version__ Indicates the version number of the XL C/C++ compiler. An integer that represents the version number
__ibmxl_release__ Indicates the release number of the XL C/C++ compiler. An integer that represents the release number
__ibmxl_modification__ Indicates the modification number of the XL C/C++ compiler. An integer that represents the modification number
__ibmxl_ptf_fix_level__ Indicates the PTF fix level of the XL C/C++ compiler. An integer that represents the fix number
__clang__ Indicates that Clang front end is used. 1
__clang_major__ Indicates the major version number of the Clang front end. 4
__clang_minor__ Indicates the minor version number of the Clang front end. 0
__clang_patchlevel__ Indicates the patch level number of the Clang front end. 1
__clang_version__ Indicates the full version of the Clang front end. 4.0.1 (tags/RELEASE_401/final)
Note:

In addition to the predefined macros for xlclang/xlclang++, you can specify -qxlcompatmacros to also define the five legacy macros listed in Table 1. This is useful when you migrate programs from IBM XL C/C++ for AIX, V13.1.3 or earlier releases to IBM XL C/C++ for AIX 16.1 that is invoked by xlclang or xlclang++.