It's a preprocessor directive that is used (for example) when you expect one of several possible -D
symbols to be defined, but none is.
#if defined(BUILD_TYPE_NORMAL)
# define DEBUG(x) do {;} while (0) /* paranoid-style null code */
#elif defined(BUILD_TYPE_DEBUG)
# define DEBUG(x) _debug_trace x /* e.g. DEBUG((_debug_trace args)) */
#else
# error "Please specify build type in the Makefile"
#endif
When the preprocessor hits the #error
directive, it will report the string as an error message and halt compilation; what exactly the error message looks like depends on the compiler.
A preprocessor error directive causes the preprocessor togenerate an error message and causes the compilation to fail.
A #error directive has the form:
.--------------------. V | >>-#--error----preprocessor_token-+----------------------------><
The argument preprocessor_token is not subject to macro expansion.
The #error directive is often used in the#else portion of a#if-#elif-#elseconstruct, as a safety check during compilation. For example,#error directives in the source file can prevent codegeneration if a section of the program is reached that should bebypassed.
For example, the directive
#define BUFFER_SIZE 255 #if BUFFER_SIZE < 256 #error "BUFFER_SIZE is too small." #endif
generates the error message:
BUFFER_SIZE is too small.