C Preprocessor Question:

Download Job Interview Questions and Answers PDF

What is #error and use of it?

C Preprocessor Interview Question
C Preprocessor Interview Question

Answer:

The use of this preprocessor is in debugging. Whenever this preprocessor is encountered during compilation the compiler would stop compilation and display the error message associated with the preprocessor in complation Output/Result Window. Depending upon compiler any other debugging information will also accompany your error message.

General form of #error is -
#error message
Also note that message doesnot need to be in double quotes.
Following source code display the use of #error preprocessor directive in C -
#include <stdio.h>
int main ()
{
#error I am Error and while i am here i will not let this program compile :-) .
return 0;
}</stdio.h>

Download C Preprocessor Interview Questions And Answers PDF

Previous QuestionNext Question
Where define directive used?What is #line?