What Is a Preprocessor Directive?
A preprocessor directive is a command, typically beginning with a hash symbol, that the preprocessor acts on before the compiler proper sees the code. Directives include files, define and expand macros, and switch blocks of code in or out based on conditions. They transform the source text, producing the final translation unit that is then compiled.
Why it matters
Because directives run before real compilation, they shape what code the compiler ultimately sees, which makes them powerful but easy to misuse. Conditional compilation and macros driven by directives are common sources of subtle build differences.
Related guides
What Is a Header Guard?A header guard is a preprocessor pattern that ensures a header file is included only once per translation uni…
What Is a Translation Unit?A translation unit is the complete source seen by the compiler after preprocessing one source file, the unit…
What Is a Forward Declaration?A forward declaration tells the compiler a name exists and its type before its full definition, letting code…