Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Introduction to Compilation Stages | Introduction to Preprocessing
C Preprocessing
course content

Conteúdo do Curso

C Preprocessing

C Preprocessing

1. Introduction to Preprocessing
2. Macros
3. Conditional compilation

book
Introduction to Compilation Stages

Preprocessing is the first stage of program compilation. But before diving into it, we need to look under the hood of the compilation process itself and understand why it’s so essential. Compilation typically consists of four stages.

Preprocessing

Preprocessing involves replacing parts of your code with other code through textual substitution. For example, when you use #include <stdio.h>, the preprocessor replaces this line with the contents of the "stdio.h" file.

This step prepares the source code for the subsequent compilation process. Internally, the output of this stage is typically a file with the .i or .ii extension (intermediate file).

Translation

After preprocessing, the compiler takes the cleaned-up code of your program, checks it for syntax and semantic errors, and translates it into assembly code - code at a lower level than C-code.

The compiler creates an assembly file with the extension .s, which contains code for a specific processor architecture.

Assembly

An object file allows the compiler to generate machine code for each source file separately. This simplifies the development of large projects, because if only one source file is changed, only that file needs to be recompiled, rather than the entire program.

An object file has the extension .o. This file contains machine instructions, but it cannot yet simply be "run" because it still depends on other files and libraries. This file is not human readable.

Linking

In this last step, the linker takes all the object files and libraries that the program needs and combines them into an one executable file with the extension .exe for Windows and without the extension on Unix-like systems.

After this step, you can simply click on your Program.exe and it will work.

question mark

Select the correct sequence of compilation steps in C:

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt