In C++, is it possible to use a string literal as a macro name?
Here's my scenario: I have a set of source files that I'd prefer to not modify, but I'd like to replace some of the string literals with other values. Here's an example:
#define "oldS开发者_StackOverflow社区tring" "newString"
No, that's not possible. If you had already used macros in place of the strings, it would have been simple to change the macro definition to use a different string -- better late than never, you might want to do it now.
No, #define
allows you to give a value to an identifier. Identifiers can't contain the quote character.
精彩评论