I am guessing from # that it is only a compile-time utility. How can it be used in C/C++ programs?
Did not find much about it on the internet. Any links would be helpful.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It causes the compiler (or preprocessor) to output the error message. In C++, it also renders the translation unit ill-formed (i.e., it causes compilation to fail).
If you have several macros that could be defined and you want to be sure that only certain combinations of them are defined, you can use
#errorto cause compilation to fail if an invalid combination is defined.It can also be useful if you want to be sure that some block of code is never compiled (for whatever reason).