Visual C 中宏中的可变长度参数++
经过多年主要使用 gcc 后,我突然需要在 Windows 上使用 Visual C++。我需要翻译的最新内容是:
#ifdef DBG_ENABLE
#define DBG_PRINT(x...) printf(x)
#else
#define DBG_PRINT(x...)
#endif
这给了我这个错误:
error C2010: '.': unexpected in macro parameter list
有人可以分享 Windows 的方法吗?
我尝试用谷歌搜索并搜索 Microsoft 文档,但无法找到一种方法来表达带来相关结果的问题。
After years of mostly using gcc, I suddenly have a need to use Visual C++ on Windows. The latest thing I need to translate is this:
#ifdef DBG_ENABLE
#define DBG_PRINT(x...) printf(x)
#else
#define DBG_PRINT(x...)
#endif
Which gives me this error:
error C2010: '.': unexpected in macro parameter list
Can someone please share the Windows way of doing this?
I tried googling and searching the Microsoft docs, but couldn't figure out a way to phrase the question that brought relevant results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
#define DBG_PRINT(x...) printf(x)
不是在 VC++ 中使用可变参数宏的正确语法。根据有关可变参数宏的 Microsoft 文档,请尝试以下操作:
或者:
#define DBG_PRINT(x...) printf(x)
is not the correct syntax for using variadic macros in VC++.Per Microsoft documentation on Variadic macros, try this instead:
Or: