在嵌套的宏中使用__va_args__,但是ARGS被截断
我正在做类似下面的事情:
#define AA(mac, a, ...) mac(a, __VA_ARGS__)
#define MAC1(a, b, c) a##b##c
AA(MAC1, 0, 1, 2)
我真正想要的是将“ AA(Mac1、0、1、2)”翻译成“ 012”,但我得到了“ 01,2”,但这是理由的,但我不是我想要。
编辑: 解决的工作是删除 va_args ,并定义一个aa,例如
#define AA(mac,a,b,c,d,e,f,g,h,...) mac(a,b,c,d,e,f,g,h)
#define MAC1(a, b, c) a##b##c
AA(MAC1, 0, 1, 2)
给我什么,“ 012”,但我不知道为什么。
I'm doing something like below:
#define AA(mac, a, ...) mac(a, __VA_ARGS__)
#define MAC1(a, b, c) a##b##c
AA(MAC1, 0, 1, 2)
what I really want is to translate "AA(MAC1, 0, 1, 2)" to "012", but I get "01,2", which is reasonalbe though, but not I want.
Edit:
A work around is to remove the VA_ARGS, and define a AA like
#define AA(mac,a,b,c,d,e,f,g,h,...) mac(a,b,c,d,e,f,g,h)
#define MAC1(a, b, c) a##b##c
AA(MAC1, 0, 1, 2)
gives what I what, "012", I don't know why though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的初始代码:
似乎可以正常工作:
因此,您的编译器或IDE可能存在问题。
Your initial code:
seems to work fine:
So, maybe there's an issue with your compiler or IDE.