Namespaces
Variants
Actions

Preprocessor

From cppreference.com
< c

The preprocessor is executed at translation phase 4, before the compilation. The result of preprocessing is a single file which is then passed to the actual compiler.

Contents

[edit] Directives

The preprocessing directives control the behavior of the preprocessor. Each directive occupies one line and has the following format:

  • # character
  • preprocessing instruction (one of define, undef, include, if, ifdef, ifndef, else, elif, elifdef, elifndef(since C23), endif, line, embed(since C23), error, warning(since C23), pragma) [1]
  • arguments (depends on the instruction)
  • line break.

The null directive (# followed by a line break) is allowed and has no effect.

[edit] Capabilities

The preprocessor has the source file translation capabilities:

  • conditionally compile of parts of source file (controlled by directive #if, #ifdef, #ifndef, #else, #elif, #elifdef, #elifndef(since C23) and #endif).
  • replace text macros while possibly concatenating or quoting identifiers (controlled by directives #define and #undef, and operators # and ##)