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.
The preprocessing directives control the behavior of the preprocessor. Each directive occupies one line and has the following format:
#
character define
, undef
, include
, if
, ifdef
, ifndef
, else
, elif
, endif
, line
, error
, pragma
) [1] The null directive (#
followed by a line break) is allowed and has no effect.
The preprocessor has the source file translation capabilities:
#if
, #ifdef
, #ifndef
, #else
, #elif
and #endif
). #define
and #undef
, and operators #
and ##
) #include
and checked with __has_include
(since C++17)) #error
) The following aspects of the preprocessor can be controlled:
#pragma
and operator _Pragma
(since C++11)) #line
) #warning
which emits a user-defined message during compilation. C documentation for preprocessor |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/preprocessor