What happens when you use gcc in C ?
Today i’m gonna talk about the compilator gcc for C language, i will explain you what does in a small details gcc, what is the preprocessor, what is the compiler, what is the assembler and what is the linker.
So the compilator gcc is decomposed in 4 process during the moment your enter the command with your file.c, like this :
After you enter this command with your file, the first process in the compilator is the preprocessor:
So what does the Preprocessor, the preprocessor will read your file and more particulary the header like “#include”, the comments you make in your file. It will “delete” theses comments and will link the file for the header you wanted. If you want to see this proceress with your file you juste need to use this command :
After that, the second process in our compilator is the compiler:
This process will transform your code into an assembly code, it will check also if there is errors in your code.
The parameters to gcc to see this process to your code is :
The third process of the compilator is the Assembler,
It will take the assembly code from the last process and will convert the assembly code to an object code, which is a compiled code that can be run on any computer with the same CPU architecture, the object code is like this :
To see this process with your file, use this parameter with gcc :
And the last process of the compilator is the Linker,
This process will combine all the object code and combine the librairies you needed for execute your file and will create an executable. This executable can be execute like this (by default) :
It’ll will run your program.
If you want to create a specific name for your executable you can use this parameter with gcc:
So, now you know all the process of the compilator gcc, i hope you learn something from this article.