Just as the title says. I want to use a preprocessor macro in the text of an #error statement:
#define SOME_MACRO 1
#if SOME_MACRO != 0
#error "SOME_MACRO was not 0; it was [value of SOME_MACRO]"
#endif
In this example I want the preprocessor to resolve [value of SOME_MACRO] to the actual value of SOME_MACRO which in this case is 1. This should happen before the preprocessor, compiler or whatever processes #error prints the error output
Is there a way to do that or is this just not possible?
I don’t want to know if there is an ISO C++ standard way to do that, because afaik the preprocessor directive #error is not stated in any ISO C++ standard. However, I know GCC and Visual C++ support #error. But my question is not specific to those compilers, I’m just curious if any C/C++ compiler/preprocessor can do that.
I tried to search for that topic but without any luck.
For completeness the C++0x way I suggested (using the same trick as Kirill):
Gives: