The overall compilation process consists of three phases: preprocessing, translation to object code, and linking. By default, a compiler invocation command invokes all phases of the compilation process to translate a program from source code to executable output. If file names for input and output files are specified when the compiler is invoked, it determines the starting and ending phases from the file name suffix (extension) of the input and output files.
You can also create a particular type of output file at any compilation phase by using appropriate compiler options. For example, invoking the xlc or xlC command with the -E or -P option performs only the preprocessing phase on the input files. The compiler invocation determines from the extension of the input file name whether to call the IBM compiler, the assembler, or the linker. The assembler and linker are tools supplied with the Linux operating system.
Related References
XL C/C++ provides a selection of base compiler invocation commands,
which support various version levels of the C and C++ languages. Each
invocation command automatically sets a compiler suboption for language level,
options for other related language features, and any related predefined
macros. In most cases, you should use the xlc command to
compile C source files and the xlC command to compile C++ source
files, or when you have both C and C++ source files. The variations of
the base command are provided to support the requirements of threaded
applications and are formed by attaching the suffix _r to a base
command.
Supported invocation commands | ||
xlc xlc++ xlC cc c89 c99 |
xlc_r xlc++_r xlC_r cc_r c89_r c99_r | The _r invocations are used for compiling thread-safe applications, also referred to as reentrant compiler invocations. |
In addition, the gxlc and gxlc++ utilities are specialized compiler invocations.
Related References
Only one object model exists for the Linux platform. If you are porting an application that relies on an object model supported on AIX (ibm or classic), you might need to modify your code. The compiler options and pragmas for specifying a particular object model are not available for Linux.
The compiler uses the file name extension to determine the appropriate compilation phase and invoke the associated tool.
The compiler accepts the following types of files as input:
Accepted input file types | ||
File type description | File name extension | Example |
---|---|---|
C and C++ source file | .c (lowercase c) for C language source files;
.C (uppercase c), .cc, .cp, .cpp, .cxx, .c++ for C++ source files | file_name.c
file_name.C, file_name.cc, file_name.cpp, file_name.cxx, file_name.c++ |
Preprocessed source file | .i | file_name.i |
Object file | .o | hello.o |
Assembler file | .s | check.s |
Archive file | .a | v1r5.a |
Loadable module or shared library file | .so | my_shrlib.so |
IPA control files (-qipa=file_name) | No naming convention for file_name is enforced. | ipa.ctl |
You can specify the following types of output files when invoking the
compiler:
Types of output files | |
File type description | Example |
---|---|
Executable file | By default, a.out |
Object files | file_name.o |
Loadable module or shared object file | file_name.so |
Assembler files | file_name.s |
Preprocessed files | file_name.i |
Listing files | file_name.lst |
Target file | file_name.d |
Related References
If you invoke the compiler without specifying any options, the behavior of the compiler is governed by the following default settings: