Understanding the GCC compiler

The official GCC logo

The GCC compiler ( gcc stands for GNU Compiler Collection ), is one of the most used compiler systems in the world and played an important role in the growth of free software basically for being under the GNU General Public License (GNU GPL).

What is a compiler?

How is GCC doing it?

* Preprocessing:

1- Removes Comments

2 -Expands Macros

3- Expands of the files included to the source code

The output will be a processed .c file sent to the standard output.

( ps: Input files that don’t require preprocessing are ignored.)

The -E flag stops “gcc” after the preprocessing stage; and before runing the compiler proper.

the preprocessed file of a simple printf(“Hello world!”) programm

* Compilation:

The -S flag stops “gcc” after the stage of compilation proper, and the output will be in the form of an assembler code file.

The content of helloworld.s

* Assembly:

The -c flag stops “gcc” after the stage of assembling.

* Linking:

The final output will be an executable file with 755 permissions.