Review:
multiple files C program
A C program can
consist of
multiple
program files:
Recall:
-
Global variables and
functions
can be
access (= used)
in
all
C program files
|
Structure of the
C compiler
- The C compiler consists of
2 separate applications:
- A
syntax analyser
and
machine code generator
program
- Check for
syntax errors
- Translates a
correct C program into
machine codes
(=
C object file)
|
- A linker ("linking loader")
program:
- Combines
the machine code
from multiple
C object files
into an
executable program
The main task
performed by the
linking loader
is to
find/locate
the
global
variables
and
functions
and
update
the
address place holders
with the
correct
reference (= memory address)
(Take a "Compiler" course if you want to
know the
details....)
|
|
|
The
process of compiling
a C program that consists of
multiple files
(1a)
Compile
each
C program file
separately:
Note:
the
C compile
uses the
data type information
in C program file 1 to
perform the
translation
The
process of compiling
a C program that consists of
multiple files
(1b)
Compile
each
C program file
separately:
Important fact:
the
data type information
in C program file 1
is
not used
in the
compilation
The
process of compiling
a C program that consists of
multiple files
(1c)
Notice that
the C compiler
requires
the
data type information to
translate
correctly:
Recall:
C programs use
declarations
to
inform the
C compiler the
data type information
The
process of compiling
a C program that consists of
multiple files
(2)
The compiled programs are
linked (= combined) into
one
executable program
The
linking process
resolves (= locates)
the
global
variable
and function names
used in all
program files
❮
❯