Types of input files

The compiler processes the source files in the order in which they are displayed. 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 linker does not run and temporary object files are removed.

By default, the compiler preprocesses and compiles all the specified source files. Although you usually want to use this default, you can use the compiler to preprocess the source file without compiling; see Preprocessing for details.

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, unless you compile with the -qsourcetype=c option.

To use the C++ compiler, the source file must have a .C (uppercase C), .cc, .cp, .cpp, .cxx, or .c++ suffix, unless you compile with the -+ or -qsourcetype=c++ option.

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 unstripped executable files serve as input to the linker. After compilation, the linker 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, unless you compile with the -qsourcetype=assembler option. Assembler files are assembled to create an object file.
Unpreprocessed assembler files
Unpreprocessed assembler files must have a .S suffix, for example, file_name.S, unless you compile with the -qsourcetype=assembler-with-cpp option. The compiler compiles all source files with a .S extension as if they are assembler language source files that need preprocessing.
Shared library files
Shared library files generally have a .a suffix, for example, file_name.a, but they can also have a .so suffix, for example, file_name.so.
Unstripped executable files
Extended Common Object File Format (XCOFF) files that have not been stripped with the operating system strip command can be used as input to the compiler. See the strip command in the AIX® Commands Reference and the description of a.out file format in the AIX Files Reference for more information.
Related information