首页 > 解决方案 > C 宏在另一个 C 宏中展开

问题描述

我有类似的东西:

#define NBR 42
#define THE_ANS_IS theAnsIsNBR

目前,第二个宏按预期扩展为“theAnsIsNBR”,但我希望它扩展为“theAnsIs42”,我不确定它是否可能!?

标签: c

解决方案


#define Paste(x, y)  x##y
#define Expand(x, y) Paste(x, y)

#define NBR 42
#define THE_ANS_IS Expand(theAnsIs, NBR)

推荐阅读