The #error directive
A preprocessor error directive causes the preprocessor to generate an error message and causes the compilation to fail.
The #error
directive is often used in
the #else
portion of a #if
–#elif
–#else
construct,
as a safety check during compilation. For example, #error
directives
in the source file can prevent code generation if a section of the
program is reached that should be bypassed.
For example, the directives
#define BUFFER_SIZE 255
#if BUFFER_SIZE < 256
#error "BUFFER_SIZE is too small."
#endif
generate the error message:
BUFFER_SIZE is too small.