Namespaces
Variants
Views
Actions

Preprocessor

From cppreference.com
< cpp
Revision as of 12:49, 28 April 2011 by WikiSysop (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:cpp/preprocessor/sidebar The preprocessor runs before the compilation begins. The result of preprocessing is single file which is then passed to the actual compiler.

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, endif, line, error, pragma)
  • arguments (depends on the instruction)

Capabilities

The preprocessor has the source file translation capabilities:

  • conditionally include of parts of source file (controlled by directive #if, #ifdef, #ifndef, #else, #elif and #endif).
  • replace text macros while possibly concatenating or quoting identifiers (controlled by directives #define and #undef, and operators # and ##)
  • include other files (controlled by directive #include)
  • cause a warning (controlled by directive #warning)
  • cause an error (controlled by directive '#error)

The following aspects of the preprocessor can be controlled: