Invoking the compiler

Different forms of the XL C/C++ compiler invocation commands support various levels of the C and C++ languages. You can use other forms of the command if your particular environment requires it.

As IBM® XL C/C++ for AIX® consists of an XL-based front end and a Clang-based front end, compiler invocations fall into two categories:
  • Category I: Legacy XL C/C++ invocations that invoke the XL-based front end, whose typical examples are xlc and xlC. In most cases, use the xlc command to compile your C source files, and the xlC command to compile C++ source files. Use xlC to link if you have both C and C++ object files.

    Table 1 lists all the compiler invocations in Category I, including the basic invocations and their corresponding special versions. Special invocations are described in Table 2.

  • Category II: Invocations for the Clang-based front end, xlclang and xlclang++.

    xlclang and xlclang++ are described in Table 3. They are introduced in IBM XL C/C++ for AIX 16.1.

For more information about the differences between the XL-based front end and the Clang-based front end, see Comparison between the XL-based and Clang-based front ends.
Note: For each invocation command, the compiler configuration file defines default option settings and, in some cases, macros; for information about the defaults implied by a particular invocation, see the /opt/IBM/xlc/16.1.0/etc/xlc.cfg file for your system.
Table 1. Compiler invocations (Category I - Legacy XL C/C++ invocations)
Basic invocations Targeted source file Description Equivalent special invocations
xlc Invokes the compiler for C source files. This command supports all of the ISO C99 standard features, and most IBM language extensions. This invocation is recommended for all applications. xlc_r, xlc_r7, xlc128, xlc128_r, xlc128_r4, xlc128_r7
c99 Invokes the compiler for C source files. This command supports all ISO C99 language features, but does not support IBM language extensions. Use this invocation for strict conformance to the C99 standard. c99_r, c99_r4, c99_r7, c99_128, c99_128_r, c99_128_r4, c99_128_r7
c89 Invokes the compiler for C source files. This command supports all ANSI C89 language features, but does not support IBM language extensions. Use this invocation for strict conformance to the C89 standard. c89_r, c89_r4, c89_r7, c89_128, c89_128_r, c89_128_r4, c89_128_r7
cc Invokes the compiler for C source files. This command supports pre-ANSI C, and many common language extensions. You can use this command to compile legacy code that does not conform to standard C. cc_r, cc_r4, cc_r7, cc128, cc128_r, cc128_r4, cc128_r7
gxlc Invokes the compiler for C source files. This command accepts many common GNU C options, maps them to their XL C option equivalents, and then invokes xlc. For more information, see Reusing GNU C/C++ compiler options with gxlc and gxlc++.  
xlc++, xlC Invokes the compiler for C++ source files. If any of your source files are C++, you must use this invocation to link with the correct runtime libraries.

Files with .c suffixes, assuming you have not used the -+ compiler option, are compiled as C language source code.

xlc++_r, xlc++_r4, xlc++_r7, xlc++128, xlc++128_r, xlc++128_r4, xlc++128_r7, xlC_r, xlC_r4, xlC_r7, xlC128, xlC128_r, xlC128_r4, xlC128_r7
xlc++core, xlCcore Invokes the compiler for C++ source files. Invokes the compiler as described above for xlc++ and xlC, but links only to the core of the runtime library. Use this invocation if you want to link your application to a runtime library other than that supplied with XL C++. xlc++core_r, xlc++core_r7, xlc++core128, xlc++core128_r, xlc++core128_r7, xlCcore_r, xlCcore_r7, xlC128core, xlC128core_r, xlC128core_r7
gxlc++, gxlC Invokes the compiler for C++ source files. This command accepts many common GNU C/C++ options, maps them to their XL C/C++ option equivalents, and then invokes xlc++. For more information, see Reusing GNU C/C++ compiler options with gxlc and gxlc++.  
Table 2. Suffixes for special invocations
128-suffixed invocations All 128-suffixed invocation commands are functionally similar to their corresponding base compiler invocations. They specify the -qldbl128 option, which increases the length of long double types in your program from 64 to 128 bits. They also link with the 128-bit versions of the C and C++ runtime libraries.
_r-suffixed invocations All _r-suffixed invocations allow for threadsafe compilation and you can use them to link the programs that use multithreading. Use these commands if you want to create threaded applications.

The _r7 invocations are provided to help migrate programs based on Posix Draft 7 to Posix Draft 10. The _r4 invocations should be used for DCE threaded applications. For more information about DCE, see Distributed computing in IBM Documentation for CICS Transaction Server for z/OS.

Table 3. Compiler invocations (Category II - Invocations for the Clang-based front end)
Invocation Description
xlclang The command supports ISO C11 standard with the exception of the atomics features. The command also supports most IBM language extensions.
xlclang++ This command supports ISO C++11 and ISO C++14 standards with some dependencies on hardware and version of AIX. This command also supports most IBM language extensions.

Related information