Compilation Process in C
The compilation in c is to compile the program by using a compiler, the compiler which we are using is gcc. There are different process involves in compile a program. The following process are:
- Pre-processor
- Compilation a. Lexical analysisb. Syntax analysis
c. Symentic analysis
d. Intermediate code generation
e. Optimization
f. Conversion to assembly language
- Assembler
- Linker/loader
Let suppose we have been taken a program program.c
Pre-processor: In program.c the preprocessor expand all the things which are written with # sign including all header files macros etc… and ignore the things which are written with in /* */ this. Then after this process the compilation process is started.
Compilation:In compilation process there are several steps involves
Lexical analysis: In lexical analysis the compiler changes or broken every statement in different tokens like int a = 20,so int is taken in 1st token a in 2nd token and so on.
Syntax analysis:In syntax analysis every statement is checked that any syntax error is there or not.
Symentic analysis:In symentic analysis every token is checked that it is written properly like int..
Intermediate code generation:In this compiler changes the code in its form..
Optimization: In this compiler changes changes the code very short form,make it very small..
Conversion to assembly language:In this the compiler changes the code in assembly language which is machine level language, then the extension of program is ‘.s ‘ in which the memory usage and some other information is given.
Assembler:In this .s extension of program is changes to .o extension which is in binary form and this is also called object file of program.
Linker/Loader:The linker links the header files to .o extension of program and make the executable a.out and save in hard disk, when we run run the program loader loads the program in RAM and execute it…