Preprocessor token expansion [duplicate]

本秂侑毒 提交于 2019-12-02 23:07:19
Simone

Read the answer to your question here:

The problem is that when you have a macro replacement, the preprocessor will only expand the macros recursively if neither the stringizing operator # nor the token-pasting operator ## are applied to it. So, you have to use some extra layers of indirection, you can use the token-pasting operator with a recursively expanded argument

Token concatenation does not expand macros when performing concatenation [ref].

To get past this, you use a level of indirection, and get the preprocessor to expand the macros before the concatenation.

#define STEP1(x, y)    STEP2(x, y)    // x and y will be expanded before the call to STEP2
#define STEP2(x, y)    x ## y         // x and y will not be expanded, just pasted
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!