Compiler Modes

Different forms of XL C/C++ compiler invocation commands support various levels of the C and C++ languages.

In most cases, you should 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.

You can use other forms of the command if your particular environment requires it. The various compiler invocation commands are:

Compiler Invocations
Basic Special
xlC xlC_r
xlc++ xlc++_r
xlc xlc_r
cc cc_r
c99 c99_r
c89 c89_r
xlCcore xlCcore_r

The basic compiler invocation commands appear as the first entry of each line above. Select a basic invocation using the following criteria:

xlC
xlc++
Both invoke the compiler so that source files are compiled as C++ language source code. If any of your source files are C++, you must use this invocation to link with the correct runtime libraries. Source files are compiled with -qalias=ansi set.

Files with .c suffixes, assuming you have not used the -+ compiler option, are compiled as C language source code when -qlanglvl=extc89 is in effect.

xlc Invokes the compiler for C source files. The following compiler options are implied with this invocation:
  • -qlanglvl=extc89
  • -qalias=ansi
  • -qcpluscmt
  • -qkeyword=inline
cc Invokes the compiler for C source files. The following compiler options are implied with this invocation:
  • -qlanglvl=extended
  • -qnoro
  • -qnoroconst
c99 Invokes the compiler for C source files, with support for ISO C99 language features. Full ISO C99 conformance requires the presence of C99-compliant header files and runtime libraries. The following options are implied with this invocation:
  • -qlanglvl=stdc99
  • -qalias=ansi
  • -qstrict_induction
  • -D_ANSI_C_SOURCE
  • -D_ISOC99_SOURCE
  • -D__STRICT_ANSI__
c89 Invokes the compiler for C source files, with support for ISO C89 language features. The following options are implied with this invocation:
  • -qlanglvl=stdc89
  • -qalias=ansi
  • -qstrict_induction
  • -qnolonglong
  • -D_ANSI_C_SOURCE
  • -D__STRICT_ANSI__
Use this invocation for strict conformance to the ANSI standard (ISO/IEC 9899:1990).
xlCcore
xlc++core
Both will invoke the compiler as described above for xlC and xlc++, but the compiler will link only to the core of the run-time library. Use this invocation if you want to link your application to a run-time library other than that supplied with XL C/C++.

IBM XL C/C++ Advanced Edition for Linux provides _r variations on the basic compiler invocations, as described below:

_r-suffixed Invocations All _r-suffixed invocations additionally define the macro names _THREAD_SAFE and __VACPP_MULTI__ , and add the -lpthreads. The compiler option -qthreaded is also added. Use these commands if you want to create Posix threaded applications.

Related Tasks

Invoke the Compiler

Related References

Compiler Command Line Options
General Purpose Pragmas
Pragmas to Control Parallel Processing
threaded IBM Copyright 2003