C++ - macro parameter substitution for string literals?
Search didn't turn up much. Is there a way to use a parameter of a macro in a string literal? For example:
#define FOO( BAR_ ) do_stuff( "BAR_" );
(so FOO( baz ) becomes do_stuff( "baz" );)
Simply writing it like that doesn't seem to work - the macro parameter is ignored inside the string.
Edit: code tags don't work the old way..
Edit n+1: whatever, I can't get any of them to work.
#define STR2(X) #X#define STR(X) STR2(X)#define FOO(BAR) do_stuff(STR(BAR))
Will work even if BAR is itself a macro.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement