开发者

In C++, is it possible to use a string literal as a macro name?

开发者 https://www.devze.com 2023-01-30 09:09 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消