DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C and C++ compilation system

Components of the C compilation system

The C compilation system consists of a preprocessor, compiler, assembler, and link editor. The cc command invokes each of these components automatically unless you use command line options to specify otherwise. An executable C program is created by exposing the source code to these components via the cc command.

C preprocessor

The preprocessor component of the compiler reads lines in your source files that direct it to replace a name with a token string (#define), perhaps conditionally (#if, for example). It also accepts directives in your source files to include the contents of a named file in your program (#include). Included header files for the most part consist of #define directives and declarations of external symbols, definitions and declarations that you want to make available to more than one source file. See ``Libraries and header files'' for details.

C compiler

The compiler proper translates the C language code in your source files, which now contain the preprocessed contents of any included header files, into assembly language code.

C assembler

The assembler translates the assembly language code into the machine instructions of the computer your program is to run on. As indicated in ``Introduction to programming in standard C and C++'', these instructions are stored in object files that correspond to each of your source files. Each object file contains a binary representation of the C language code in the corresponding source file. Object files are made up of sections, of which there are usually at least two. The text section consists mainly of program instructions. Text sections normally have read and execute, but not write, permissions. Data sections normally have read, write, and execute permissions. See ``Object files'' for details of the object file format.

C linker

The link editor links these object files with each other and with any library functions that you have called in your program. When it links with the library functions depends on the link editing model you have chosen.

See ``Link editing'' for more information on the two ways in which libraries are implemented, and details on how to combine the static and dynamic linking approaches in different ways according to your needs.

Organization of the C compilation system

``Organization of C Compilation System'' shows the organization of the C compilation system. Details concerning the optimizer are omitted here because it is optional. See ``Commonly used command line options'' for more information concerning invoking the optimizer.

Organization of C Compilation System


Next topic: Components of the C++ compilation system
Previous topic: Compiling and linking

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005