Last Updated: June 6, 2026
Every C++ source file goes through the preprocessor before the compiler sees it. The preprocessor is a line-oriented text rewriter that recognizes lines beginning with # as directives and transforms the source according to them. This chapter covers the full directive set: #include for pulling in headers, #define and #undef for managing macro names, the conditional compilation family (#if, #ifdef, #ifndef, #elif, #else, #endif), #pragma for compiler-specific instructions, include guards, the diagnostic directives #error and #warning, and the rarely seen #line. The chapter closes with why modern C++ replaces most preprocessor uses with constexpr, inline, and enum class.