The compiler processes the source files in the order in which they appear. If the compiler cannot find a specified source file, it produces an error message and the compiler proceeds to the next specified file. However, the link editor will not be run and temporary object files will be removed.
Your program can consist of several source files. All of these source files can be compiled at once using only one invocation of the compiler. Although more than one source file can be compiled using a single invocation of the compiler, you can specify only one set of compiler options on the command line per invocation. Each distinct set of command-line compiler options that you want to specify requires a separate invocation.
By default, the compiler preprocesses and compiles all the specified source files. Although you will usually want to use this default, you can use the compiler to preprocess the source file without compiling by specifying either the -E or the -P option. If you specify the -P option, a preprocessed source file, file_name.i, is created and processing ends.
The -E option preprocesses the source file, writes to standard output, and halts processing without generating an output file.
You can input the following types of files to the XL C/C++ compiler:
C and C++ source files | These are files containing C or C++ source
code.
To use the C compiler to compile a C language source file, the source file must have a .c (lowercase c) suffix, for example, mysource.c. To use the C++ compiler, the source file must have a .C (uppercase C), .cc, .cp, .cpp, .cxx, or .c++ suffix. To compile other files as C++ source files, use the -+ compiler option. All files specified with this option with a suffix other than .a, .o, .so, or .s, are compiled as C++ source files.
|
Preprocessed source files | Preprocessed source files have a .i suffix, for example, file_name.i. The compiler sends the preprocessed source
file, file_name.i, to the compiler where it is preprocessed
again in the same way as a .c or .C file. Preprocessed
files are useful for checking macros and preprocessor directives.
|
Object files | Object files must have a .o suffix, for example, file_name.o. Object files, library files, and nonstripped executable
files serve as input to the linkage editor. After compilation, the linkage
editor links all of the specified object files to create an executable file.
|
Assembler files | Assembler files must have a .s suffix, for example, file_name.s. Assembler files are assembled to create an object file. |
Assembler-with-cpp | Assembler files must have a .S suffix, for example, file_name.S. The compiler compiles all source files with .S extension as if they are assembler language source files that needs preprocessing. |
Shared library files | Shared library files must have a .so suffix, for example file_name.so.
|
Nonstripped executable files | Executable and linking format (ELF) files that have not been stripped with the Linux strip command can be used as input to the compiler. |
Related information