VC++允许 /##/ 作为宏的值 - 如何在 eclipse/mingw-gcc 中处理它?
我正在尝试在 eclipse/mingw-gcc 中编译一个真正的 win32 应用程序,到目前为止还很不成功(参见 https://stackoverflow.com/ questions/9162976/how-to-compile-a-win32-application-in-eclipse-using-the-mingw-gcc-toolchain)
无论如何,在排除另一个错误时,以下行在文件 c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\WTypes.h 中引起了我的好奇:
#define _VARIANT_BOOL /##/
它在 struct tagVARIANT 来自 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\OAIdl.h:
VARIANT_BOOL boolVal;
_VARIANT_BOOL bool;
SCODE scode;
扩展为:
VARIANT_BOOL boolVal;
SCODE scode;
因为 /##/
被扩展为//
,开始评论!我不相信它符合标准,并且确实尝试在 mingw-gcc 中编译失败:
pasting "/" and "/" does not give a valid preprocessing token ComHelpers line 445, external location: o:\C\wsdk\Include\oaidl.h C/C++ Problem
因此,我正在寻找有关如何解决此问题的建议。
I am trying to compile a real win32 application in eclipse/mingw-gcc, quite unsuccessfully until now (see https://stackoverflow.com/questions/9162976/how-to-compile-a-win32-application-in-eclipse-using-the-mingw-gcc-toolchain)
Anyway, while troubleshooting yet another error, the following line in the file c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\WTypes.h has caught my curiosity:
#define _VARIANT_BOOL /##/
It is used within the struct tagVARIANT
from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\OAIdl.h:
VARIANT_BOOL boolVal;
_VARIANT_BOOL bool;
SCODE scode;
which expands to:
VARIANT_BOOL boolVal;
SCODE scode;
Because /##/
is expanded to //
, which starts a comment! I do not believe it is compliant to the standard and indeed trying to compile in mingw-gcc fails with:
pasting "/" and "/" does not give a valid preprocessing token ComHelpers line 445, external location: o:\C\wsdk\Include\oaidl.h C/C++ Problem
So, I am looking for advices on how to solve this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要弄清楚宏在什么条件下具有问题定义,并在这种情况下取消定义它。如果没有办法判断,那就无条件取消定义它,希望没问题。 :(
You'll need to figure out under what conditions the macro has the problem definition, and undef it in that case. If there's no way to tell, then just undef it unconditionally, and hope that's ok. :(