| 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) | ||||
#error#warning (C++23) | ||||
(C++11) | ||||
(C++26) |
Shows the given error message and renders the program ill-formed, or shows the given warning message without affecting the validity of the program(since C++23).
Contents |
#errordiagnostic-message | (1) | ||||||||
#warningdiagnostic-message | (2) | (since C++23) | |||||||
diagnostic-message can consist of several words not necessarily in quotes.
Before its standardization in C++23,#warning has been provided by many compilers in all modes as a conforming extension.
#if __STDC_HOSTED__ != 1# error "Not a hosted implementation"#endif #if __cplusplus >= 202302L# warning "Using #warning as a standard feature"#endif #include <iostream> int main(){std::cout<<"The implementation used is hosted\n";}
Possible output:
The implementation used is hosted
C documentation forDiagnostic directives |