General topics | ||||||||||||||||
| ||||||||||||||||
Flow control | ||||||||||||||||
Conditional execution statements | ||||||||||||||||
Iteration statements (loops) | ||||||||||||||||
Jump statements | ||||||||||||||||
Functions | ||||||||||||||||
Function declaration | ||||||||||||||||
Lambda function expression | ||||||||||||||||
inline specifier | ||||||||||||||||
Dynamic exception specifications(until C++17*) | ||||||||||||||||
noexcept specifier(C++11) | ||||||||||||||||
Exceptions | ||||||||||||||||
Namespaces | ||||||||||||||||
Types | ||||||||||||||||
Specifiers | ||||||||||||||||
| ||||||||||||||||
Storage duration specifiers | ||||||||||||||||
Initialization | ||||||||||||||||
Expressions | ||||||||||||||||
Alternative representations | ||||||||||||||||
Literals | ||||||||||||||||
Boolean -Integer -Floating-point | ||||||||||||||||
Character -String -nullptr(C++11) | ||||||||||||||||
User-defined(C++11) | ||||||||||||||||
Utilities | ||||||||||||||||
Attributes(C++11) | ||||||||||||||||
Types | ||||||||||||||||
typedef declaration | ||||||||||||||||
Type alias declaration(C++11) | ||||||||||||||||
Casts | ||||||||||||||||
Memory allocation | ||||||||||||||||
Classes | ||||||||||||||||
Class-specific function properties | ||||||||||||||||
| ||||||||||||||||
Special member functions | ||||||||||||||||
Templates | ||||||||||||||||
Miscellaneous | ||||||||||||||||
(C++23)(C++23) | ||||
(C++17) | ||||
(C++23) | ||||
(C++11) | ||||
(C++26) |
The preprocessor is executed attranslation phase 4, before the compilation. The result of preprocessing is a single file which is then passed to the actual compiler.
Contents |
The preprocessing directives control the behavior of the preprocessor. Each directive occupies one line and has the following format:
Themodule and import directives are also preprocessing directives. | (since C++20) |
Preprocessing directives must not come from macro expansion.
#define EMPTYEMPTY# include <file.h> // not a preprocessing directive
The preprocessor has the source file translation capabilities:
The following aspects of the preprocessor can be controlled:
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
CWG 2001 | C++98 | the behavior of using non-standard-defined directives was not clear | made conditionally-supported |
C++ documentation forPredefined Macro Symbols | |
C++ documentation forMacro Symbol Index | |
C documentation forpreprocessor |