Preprocessor & Advanced C
The preprocessor runs BEFORE compilation — macros, conditional compilation, and header guards. Understanding it is essential for reading C system code and libraries.
30 min•By Priygop Team•Last updated: Feb 2026
Preprocessor & Systems
- #define — Object-like macros: #define MAX_SIZE 100. Function-like: #define MAX(a,b) ((a)>(b)?(a):(b)). Replaced before compile
- #ifdef / #ifndef — Conditional compilation. Header guards: #ifndef HEADER_H #define HEADER_H ... #endif
- #include — < > for system headers, " " for project headers. Preprocessor copies file contents inline
- Variadic macros — #define LOG(fmt, ...) printf(fmt, __VA_ARGS__). Debug logging macros
- System calls — fork(), exec(), pipe(), signal(). Interface between programs and the OS kernel
- POSIX threads — pthread_create(), pthread_join(), pthread_mutex. Multi-threaded C programs
- Socket programming — socket(), bind(), listen(), accept(). Build network servers and clients in C
- Volatile keyword — volatile int flag. Tells compiler not to optimize — value may change externally (hardware, signal handlers)