The approach to concatenate in C/C++ in a preprocessor macro is to use ##. The approach to stringify is to use #. I'm trying to concat AND stringify. This is generating a warning from g++ (3.3.2)
#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y) // concat
#define TOKENPASTE3(x, y) TOKENPASTE(#x, #y) // concat-stringify (warnings)
const char* s = TOKENPASTE3(Hi, There)
It is not acceptable to get the warning
"test_utils/test_registration.h:34:38: warning: pasting ""Hi"" and ""There"" does not give a valid preprocessing token"
although (using the -E option) I see that it generates:
const char* s = "Hi""There";
Which looks right to me.
Any help will be appreciated.
#xand#y; you don't need to concat them into a single token, just use#x #y."Hi" "There"will be interpreted as"HiThere"even without doing so.