Diagnostics
5 Diagnostics
The directive ‘#error
’ causes the preprocessor to report a fatal error. The tokens forming the rest of the line following ‘#error
’ are used as the error message.
You would use ‘#error
’ inside of a conditional that detects a combination of parameters which you know the program does not properly support. For example, if you know that the program will not run properly on a VAX, you might write
#ifdef __vax__ #error "Won't work on VAXen. See comments at get_last_object." #endif
If you have several configuration parameters that must be set up by the installation in a consistent way, you can use conditionals to detect an inconsistency and report it with ‘#error
’. For example,
#if !defined(FOO) && defined(BAR) #error "BAR requires FOO." #endif
The directive ‘#warning
’ is lik