Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of the #error directive in C?

What is the #error directive in C? What is the use of it?

like image 430
PHP Avatar asked Mar 16 '11 05:03

PHP


People also ask

What kind of word is the?

As detailed above, 'the' can be an adverb or a determiner. Adverb usage: The hotter, the better. Adverb usage: The more I think about it, the weaker it looks.


1 Answers

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.

like image 107
geekosaur Avatar answered Oct 04 '22 12:10

geekosaur