Skip to content
Latchkey

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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →