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
For completeness the C++0x way I suggested (using the same trick as Kirill):
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#define EXPECT(v,a) static_assert((v)==(a), "Expecting " #v "==" STRING(a) " [" #v ": " STRING(v) "]")
#define VALUE 1
EXPECT(VALUE, 0);
Gives:
g++ -Wall -Wextra -std=c++0x test.cc
test.cc:9: error: static assertion failed: "Expecting VALUE==0 [VALUE: 1]"