小编ali*_*ice的帖子

c预处理器将多个参数作为一个传递

C预处理器传递多个参数,就好像它们是单个参数一样.我非常确定问题是我们如何调用untouchable宏,但是我们为改变first宏所做的每一次尝试都未能产生预期的结果.这是一个包含注释的完整代码示例,用于解释发生了什么以及我们想要发生什么:

//this can be changed, but it must remain a #define to be of any use to us
#define first a,b,c

// v all code below this line cannot be altered (it's outside of our control)

#define untouchable(name, c1, c2, c3) \
    wchar_t name[] = \
    { \
        quote(c1), \
        quote(c2), \
        quote(c3) \
    }

#define quote(c) L#@c

// ^ all code above this line cannot be altered (it's outside of our control)

int _tmain(int argc, …
Run Code Online (Sandbox Code Playgroud)

c macros c-preprocessor

12
推荐指数
2
解决办法
1610
查看次数

标签 统计

c ×1

c-preprocessor ×1

macros ×1