Reputation: 257
We are using a method
#define CM_VALUE_1 CM_Method(3001)
CM_Method is a method define in same file .
I just want to print CM_Method(3001)
by using CM_VALUE_1
in vc++
Upvotes: 1
Views: 134
Reputation: 70382
Use the stringize preprocessor operator indirectly to get what you want.
#define MAKE_STR(X) #X
#define MAKE_STR2(X) MAKE_STR(X)
std::cout << MAKE_STR(CM_VALUE_1)
<< " is " << MAKE_STR2(CM_VALUE_1)
<< std::endl;
will result in
CM_VALUE_1 is CM_METHOD(3001)
If the parameter to MAKE_STR2
is itself a macro, it is expanded when calling MAKE_STR
, so the outcome is the stringization of what the parameter was defined to be, rather than the macro name itself.
Upvotes: 5