What happens when you type GCC main.c?
GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language.
Four Steps of Compilation: preprocessing, compiling, assembly, linking.
The different options of the GCC command allow the user to stop the compilation process at different stages.
#1- Preprocessing:
The preprocessor obeys commands that begin with # (known as directives) by removing comments, expanding macros, and expanding included files.
If you included a header file such as #include <stdio.h>, it will look for the stdio.h file and copy the header file into the source code file.
The preprocessor also generates macro code and replaces symbolic constants defined using #define with their values.
#2- Compiling:
It takes the output of the preprocessor and generates assembly language, an intermediate human readable language, specific to the target processor.
#3- Assembly:
The assembler (assembly language) converts the code into pure binary code (0 and 1).
#4- Linking:
If we are using a function from libraries, the linker will link our code with that library function code.