Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Compiling

&pagelevel(4)&pagelevel

C sources are compiled with the ccc11 and c89 commands and C++ sources with the CC command.

These commands are described in detail in chapter "The cc, c11, c89 and CC commands".

C and C++ language modes

The C and C++ sources can be compiled in various language modes via the following options:

C language modes (cc/c11/c89 commands):

  • extended c11 mode (-X 2011 -X nostrict), default for cc and c11

  • strict c11 mode (-X 2011 -X strict)
  • extended c89 mode (-X 1990 -X nostrict), default for c89
  • strict c89 mode (-X 1990 -X strict)
  • Kernighan&Ritchie C (-X kr)

C++ language modes (CC command):

  • extended C++ 2020 mode (-X 2020 -X nostrict), default
  • strict C++ 2020 mode (-X 2020 -X strict)
  • extended C++ 2017 mode (-X 2017 -X nostrict)
  • strict C++ 2017 mode (-X 2017 -X strict)
  • extended C++ V3 mode (-X v3-compatible -X nostrict)

  • strict C++ V3 mode (-X v3-compatible -X strict)
  • Cfront C++ mode (Cfront-V3.0.3-compatible C++) (-X v2-compatible)

See "Options for selecting the language mode" for the language mode options.

Creating an object file (“.o” file)

If the compilation run is not terminated after the preprocessor phase (see the -E and -P options on "Options for selecting compilation phases"), the compiler creates an LLM for each compiled source file and stores it by default in a POSIX object file named basename.o in the current directory. basename is the name of the source file without the directory part or the standard suffixes (.c, .C etc.).

A different directory and/or file name may be defined for the object file with the -o option (see "General options").

By default, a link run is started after compilation. If only one source file is compiled and linked in one step, the object file is stored temporarily and then deleted. If at least two source files or one source and one object file (.o file) are specified, the object files are not deleted.

Linking can be prevented by specifying the -c option (see "Options for selecting compilation phases (C/C++ POSIX Commands, #29)").

Creating an expanded, recompilable source program (“.i” file)

If the -P option is specified, only the preprocessor run is executed and one expanded, recompilable source program is generated for each compiled source file. The result is written by default into a POSIX source file named basename.i (cc, c11c89) or basename.I (CC) in the current directory.

The -o option can be used to specify a different destination directory and/or file name for the expanded source program (see "General options ").

Creating compilation listings

The -N listing option can be used to request various compiler listings (e.g. source/error listing, cross-reference listing, etc.). The compiler either writes the requested listings separately for each compiled source file into a list file named basename.lst or collectively for all compiled source files into a list file file specified with the -N output option (see "Options for outputting listings and CIF information)").

You can also create CIFs (Compilation Information Files) for the output of compilation listings, which are subsequently processed with the global listing generator cclistgen. See the -N cif option ("Options for outputting listings and CIF information") and chapter “Global listing generator (cclistgen)”.

List files can be printed out with the POSIX bs2lp command (see the manual “POSIX Commands” [3]).

Output destinations and codeset

The compiler saves the output files by default in the current directory, i.e. in the directory from which the compiler run was started.

The -o option (see "General options") can be used to specify a different directory and/or file name as the output destination. This can be a directory in the local POSIX file system or in a merged in file system on a remote host. However, it must be noted that it is only meaningful to further process text files on UNIX hosts or PCs, i.e. only expanded source programs (“.i” files) and list files (“.lst” files).

The codeset of the destination file system determines the output codeset used for the files (ASCII or EBCDIC) itf the environment variable IO-CONVERSION has the value YES (see sections "Environment variables" und "Support for file systems in ASCII" in manual "C Library Functions for POSIX Applications“ [2] ).

How characters and strings are stored is controlled by the -K literal_encoding_... option (see "Common frontend options in C and C++").