Preprocessor Directives & Macro Hazards

🟡 Intermediate

📖 Definition

The preprocessor transforms source code text before actual compilation using directives (#include, #define, #ifdef). In modern C++, prefer constexpr constants and inline functions over raw preprocessor macros.

💡 Code Example

#include <iostream>

#define ENABLE_LOGGING 1

int main() {
#if ENABLE_LOGGING
    std::cout << "Logging enabled at compile time.\n";
#endif
    return 0;
}