How the Compiler Works for Creating an Executable File From a Source File
— What happens when you type gcc main.c?
The computer was invented over 70 years since 1946. It has been developed, iterated, and become super powerful as of today. However, the mechanism of how a computer handles the data hasn’t been changed much. It still only recognizes the electronic signal — on and off, which means 0 and 1.
Unfortunately, these codes are only readable for a machine but not human beings. Then how our order is translated into 0–1 code for the computer to execute? There will be 4 steps and let’s use printing “Hello World!” as an example.
#0 Create .c source file
Print a string “Hello World!” on the screen and save it as a .c file hello_world.c
#1 Preprocess
Syntax : gcc -E hello_world.c
The preprocessor removes all the lines of comments since these are only for humans to understand what this program is about and the computer doesn’t need them to run the program. Another work the preprocessor does is linking all the functions we need…