Module 5: The C Preprocessor

A separate language living inside your .c files

Lessons

IDTitleDuration
5-1How the Preprocessor Works20 min
5-2define: Constants and Object-Like Macros20 min
5-3Function-Like Macros Done Right30 min
5-4Conditional Compilation20 min
5-5X-Macros and Makefiles30 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).