Contenido del Curso
C Preprocessing
Introduction to Compilation Stages
Preprocessing is the first stage of program compilation. But first we must look under the hood of such a process as compilation and understand why we need it so much
The process of converting program text into instructions for the computer is called compilation.
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.
¡Gracias por tus comentarios!