The C ompilition process
- A
single file
C program is
processed by the
following
programs:
- The C
preprocessor
- The C
compiler
- The C
assembler
|
|
The compilation process of a
C program
Step 1:
run the
C pre-processor
on the C program
The C pre-processor
provide a sophisticated
text re-writing system
that handles:
- Inclusion of
header files
- Definition/replacement of
constants
-
conditional compilation
|
The compilation process of a
C program
Step 2:
run the
C compiler
to translate the
C source into
low level assembler
instructions:
The compilation process of a
C program
Step 3:
run the
assembler
to translate the
program in assembler instructions into
binary
machine
instructions:
Tasks performed by the
C pre-processor
-
Remove
all comments
from a C program:
// comment ----> (empty)
/* ........ */ ----> (empty)
|
-
Read in and
process
include (header) files:
#include "header1.h"
or: #include <header2.h>
|
- Process
the
macro (symbolic) definitions:
#define macroName(x, y) macro-definition
|
.... continued on
next slide....
|
Tasks performed by the
C pre-processor
-
Conditional inclusion (1):
include a
text segment
when some symbol
is
defined:
#ifdef symbol
This text segment is included
if "symbol" is defined
#endif
|
-
Conditional inclusion (2):
include a
text segment
when some symbol
is
not defined:
#ifndef symbol
This text segment is included
if "symbol" is not defined
#endif
|
|
❮
❯