What happens when you type gcc main.c
A compiler is a kind of translator that transforms a program written in a certain language to another, which is usually the machine language, this allows the computer to understand and execute the instructions of the program (what we want the computer to do for us).
gcc is a compiler capable of receiving a source program in languages such as C and Fortran, to use it just simply indicate the name of the file that contains our source code:
Behind this simple instruction there is a very interesting process, let’s see step by step what happens when writing gcc main.c
The compilation process
At this stage the directives are interpreted to the preprocessor. Among other things, the variables initialized with #define are substituted in the code for their value in all places where their name appears.
The compilation transforms the C code into the assembly language of our machine’s processor.
The assembly transforms the program written in assembly language to object code, a binary file in machine language executable by the processor.
It is a program that takes the objects generated in the first steps of the compilation process, the information of all the necessary resources (library), removes those resources that it does not need, and links the object code with its library (s) with what finally produces an executable file or a library