The #error
Conditional Directive
The #error
directive takes a string as an argument and produces an error message at
compile-time. Errors produced by this directive are displayed as normal
compiler errors.
Like the
#warning directive, this directive is most useful for detecting pre-defined
constraints and inconsistencies during preprocessing of the source file.
Syntax
#error <message
string>
The message
string identifier shown above indicates the error message to be displayed.
The following example illustrates use of the #error directive:
#if DEBUG
...
#elif RETAIL
...
#else
#error DEBUG or RETAIL must be defined!
#endif
When the error
above is encountered, the following line will be output:
#error 'DEBUG or RETAIL must be defined' (J0500)
|