What happens when you type gcc main.c?

Tadeo Grach
1 min readSep 18, 2020

--

GCC

gcc is the C compiler of choice for most UNIX. The program gcc itself is actually just a front end that executes various other programs corresponding to each stage in the compilation process.

.c

A C file is a source code file for a C or C++ program. And .c is the C file extension.

Steps of compilation

There are 4 steps:

Preprocessor:

This is the first step, this places all files into your .c file, and it also translates all macros into inline C code.

Compiler:

Compiler convert files genereted by preprocessor as an imput and generetes an assembly code.

Assember:

Our machine can only read binary, we need to convert the assembly code so the machine can read it. This is what the Assember step does.

Linker:

This step will link our object code with the library code and generate it exe files.

gcc main.c

So when we type gcc main.c, we are compiling the main.c file and making an executable code.

--

--

Tadeo Grach
Tadeo Grach

No responses yet