ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

C Programming Tutorial• 6 min read

C Introduction & The 4 Compilation Stages

Preprocessor, Compiler, Assembler, and Linker

Created in 1972 by Dennis Ritchie at Bell Labs to write the UNIX operating system, C is the bedrock of modern computing: Linux, Windows, macOS, Git, and Python are all implemented in C.

The 4 Stages of C Compilation

1Preprocessing (gcc -E): Strips comments, expands #include header files, and evaluates #define macros.
2Compilation (gcc -S): Translates pure C code into CPU assembly instructions.
3Assembly (gcc -c): Assembles assembly instructions into binary machine code object files (.o).
4Linking (gcc): Merges object files with system standard libraries (e.g. libc) into a final runnable executable binary.
Canonical Hello World in C (main.c)
#include <stdio.h>

int main(void) {
    printf("Hello, Codexia Systems Engineering!\n");
    return 0; // 0 indicates successful execution to the OS
}
stdio.h provides standard input/output functions like printf.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which stage of the C build pipeline expands `#include` header files and `#define` macros before compilation?