7.7 Error Directives

Error directives produce compile-time error messages.

Syntax

control-line : #error preprocessor-tokens opt new-line

The error messages include the argument preprocessor-tokens, which is subject to macro expansion. These directives are most useful for detecting programmer inconsistencies and violation of constraints during preprocessing. The following example demonstrates error processing during preprocessing.

#if !defined(error_chk)

#error No error checking enabled.

#endif

If the error_chk constant is not defined at compile time, the

No error checking enabled

message prints on the screen along with other compiler messages.