Expand macro inside string literal

后端 未结 2 1888
轻奢々
轻奢々 2020-12-03 17:21

What I\'m trying to do is to #define a macro:

#define a(2)

and later use it inside a string literal: string = \"a\";

2条回答
  •  盖世英雄少女心
    2020-12-03 17:37

    No, you cannot do macro expansion INSIDE string literals (i.e. having the preprocessor to look inside literals for macros to expand).

    You can have a macro expansion to produce a string literal using the stringify operator (#). But that's a different thing.

提交回复
热议问题