Thursday, July 12, 2012

Stages of Compilation


1. Preprocessing 

Performed by a program called the preprocessor.
Modifies the source code (in RAM) according to preprocessor directives (preprocessor commands) embedded in the source code.
Strips comments and  white space from the code.
The source code as stored on disk is not modified.





2.Compilation


Performed by a program called compiler.
Translate the source code in to machine code (binary code).

Checks for syntax errors and warnings

Saves the object code to a disk file, if instructed to do so (we will not do this).

If any compiler errors are received, no object code file will be generated.

An object code file will be generated if only warnings, not errors, are received.


3.Linking

Combines the program object code with other object code to produce the executable file.
The other object code can come from the Run-Time Library, other libraries, or object files that you have created.
Saves the executable code to a disk file.  On the Linux system, that file is called a.out.
If any linker errors are received, no executable file will be generated.





No comments:

Post a Comment