Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

#warning directive

Use case

Emit compiler warnings from preprocessor.

Explanation

#warning emits a warning during compilation.

Code

#include <cstdint>

#if INTPTR_MAX == INT32_MAX
#warning "32-bit build. Address space limited."
#endif

int main() { return 0; }

View on GitHub.

Output

$ ./src/c++23/build/warning-directive