Preprocessor Error Directive - #error

Syntax

A preprocessor #error directive causes the preprocessor to generate an error message and causes the compilation to fail.

Use the #error directive as a safety check during compilation. For example, if your program uses preprocessor conditional compilation directives, put #error directives in the source file to prevent code generation if a section of the program is reached that should be bypassed.

For example, the directive

#error Error in the TESTPGM1 - This section should not be compiled.

generates the following error message:

Error in TESTPGM1 - This section should not be compiled


Preprocessor Directives - An Overview


Conditional Compilaton - #if, #elif
Conditional Compilaton - #ifndef
Conditional Compilaton - #else
Example of Preprocessor Directives