Shows the given error message and renders the program ill-formed, or given warning message without affect the validity of the program(since C23).
#error diagnostic-message | (1) | |
#warning diagnostic-message | (2) | (since C23) |
#error directive, an implementation displays the message diagnostic-message and renders the program ill-formed (the compilation stops).diagnostic-message can consist of several words not necessarily in quotes.
Before its standardization in C23, #warning has been provided by many compilers in all modes as a conforming extension.
#if __STDC__ != 1
# error "Not a standard compliant compiler"
#endif
#if __STDC_VERSION__ >= 202311L
# warning "Using #warning as a standard feature"
#endif
#include <stdio.h>
int main (void)
{
printf("The compiler used conforms to the ISO C Standard !!");
}Possible output:
The compiler used conforms to the ISO C Standard !!
| C++ documentation for Diagnostic directives |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/c/preprocessor/error