What happens when you type gcc main.c
I will explain it step by step to understand it better:
GCC (GNU C Compiler) is an integrated compiler of the GNU project for C, C ++, etc. This receives a source program and generates a binary executable program in the language of the local machine.
Syntax.
gcc [option] [file]
Suffixes
Extensions or suffixes of file names are common: .c (C source) in other words main.c is a file in source c.
The gcc main.c command compiles the program and generates an a.out executable file.
The compilation process involves four successive stages:
Preprocessing
This stage modifies the source code according to the directives that the programmer has written, these directives are recognized because they start with the # character and these are replaced in the code.
compilation
This stage transforms the C code into the language of our machine’s own processor.
Assembly
This stage transforms the program written in assembly language to object code, a binary file in machine language executable by the processor.
Linking
This stage incorporate in some way the binary code of these functions to our executable.