Preprocessing
Preprocessing
At the outset, the C preprocessor comes into play. It handles preprocessor directives, which
begin with a '#' symbol, and includes header files in the code. When you use #include <stdio.h>,
for example, the preprocessor replaces it with the content of the stdio.h file. This step generates
an intermediate code with all the necessary declarations and macros.
Once preprocessing is complete, the actual compilation commences. The compiler takes the C
code and translates it into assembly code, specific to the target platform. Assembly code
represents a low-level view of the program, consisting of instructions that the processor can
execute.
Next, the assembler converts the assembly code into machine code, also known as object code.
The object code consists of binary representations of instructions and data. This step is a crucial
bridge between human-readable code and the language the computer understands.
Now that we have object files with machine code, the linker takes center stage. It resolves
external dependencies, such as functions from libraries or other object files, and combines all the
object files into a single executable. The linker ensures that the final program is self-contained
and ready to run.