What goes inside the compilation process?
A compiler converts a C program into an executable. There are four phases for a C program to become an executable:
- Pre-processing
- Compilation
- Assembly
- Linking
By executing the below command, we get all intermediate files in the current directory along with the executable.
$gcc -Wall -save-temps filename.c –o filename
The following screenshot shows all generated intermediate files.
Let us one by one see what these intermediate files contain.
Compiling a C Program: Behind the Scenes
The compilation is the process of converting the source code of the C language into machine code. As C is a mid-level language, it needs a compiler to convert it into an executable code so that the program can be run on our machine.
The C program goes through the following phases during compilation: