Module 5: The C Preprocessor
A separate language living inside your .c files
Lessons
| ID | Title | Duration |
|---|---|---|
| 5-1 | How the Preprocessor Works | 20 min |
| 5-2 | define: Constants and Object-Like Macros | 20 min |
| 5-3 | Function-Like Macros Done Right | 30 min |
| 5-4 | Conditional Compilation | 20 min |
| 5-5 | X-Macros and Makefiles | 30 min |
Project
| 5-proj | Project: Debug Logging System | 50 min |
Key Concepts
preprocessor, compilation-pipeline
PDF Status
- PDF ch06 (The C Preprocessor) — Complete (written 2026-04-08).
- Key Concepts: four preprocessor operations, object/function-like macros, parenthesisation rule, # and operators, predefined macros table, include guards vs pragma once, VA_ARGS fix.
- Going Deeper: double-evaluation and missing-parens bugs with fixes (inline function vs GNU extension), conditional compilation + feature-test macros (_POSIX_C_SOURCE/_GNU_SOURCE), X-macro pattern (STATE_LIST → enum + string table + transition table), _Generic with safe_max and type_name, limits of _Generic.
- Real-World Connection: Linux kernel include/linux/kernel.h — container_of (typeof + offsetof), BUILD_BUG_ON (zero-length array compile-time assertion), likely/unlikely (__builtin_expect branch hints).
- Exercises 6.1–6.4 + fully annotated solutions + test files (includes platform.h).