CITS2002 Systems Programming  
next CITS2002 CITS2002 schedule  

What is cc really doing - the condensed version

We understand how cc works in its simplest form:

  • we invoke cc on a single C source file,
  • we know the C-processor is invoked to include system-wide header files, and to define our own preprocessor and definitions macros,
  • the output of the preprocessor becomes the input of the "true" compiler,
  • the output of the compiler (for correct programs!) is an executable program (and we may use the -o option to provide a specific executable name).

 

What is cc really doing - the long version

Not surprisingly, there's much more going on!

cc is really a front-end program to a number of passes or phases of the whole activity of "converting" our C source files to executable programs:

  1. foreach C source file we're compiling:

    1. the C source code is given to the C preprocessor,
    2. the C preprocessor's output is given to the C parser,
    3. the parser's output is given to a code generator,
    4. the code generator's output is given to a code optimizer,
    5. the code optimizer's output, termed object code, is written to a disk file termed an object file,

  2. all necessary object files (there may be more than one, and some may be standard C libraries, operating system-specific, or provided by a third-party), are presented to a program named the linker, to be "combined" together, and

  3. the linker's output is written to disk as an executable file.

 


CITS2002 Systems Programming, Lecture 12, p1, 6th September 2019.