问题描述
WinNT.h在VS2008 SP1安装中有以下几行:
WinNT.h has the following lines in it, in the VS2008 SP1 install:
#define BitTest _bittest
#define BitTestAndComplement _bittestandcomplement
#define BitTestAndSet _bittestandset
#define BitTestAndReset _bittestandreset
#define InterlockedBitTestAndSet _interlockedbittestandset
#define InterlockedBitTestAndReset _interlockedbittestandreset
我有一些基于BitTest<>()的模板
I have a number of templates that are based on BitTest<>()
任何人都知道一个简单的方法禁用这些#defines?
通常,MS提供一个#define XXX符号,如果定义,将禁用一些违规部分的标题 - 例如NOMINMAX。
Oftentimes MS does provide a #define XXX symbol which, if defined, will disable some offending portion of their header - e.g. NOMINMAX.
我无法找到解决上述问题的方法。
I have been unable to find such a solution to the above problem.
与微软的许多可疑的选择,阅读。如果没有,请停在这里。 ;)
If you share frustration with Microsoft's many dubious choices, the read on. If not, stop here. ;)
编辑:
- 为什么Microsoft不能使用
_bittest本身??? - 或者为什么他们不能使用BITTEST像每个人都知道你
应该 - 总是使用全帽的
宏! - 2010年,微软仍然在#defining
的事情? WTF?
推荐答案
不幸的是,Microsoft认为可以使他们的API使用宏名称,因为他们为95%或更多的API做它们,以使它们对ANSI和Unicode API透明地工作。
Unfortunately, Microsoft believes it's OK to make their APIs use macros for names since they do it for 95% or more of their APIs to make them work 'transparently' for ANSI vs. Unicode APIs.
看起来不像他们提供的一个干净的方式来防止宏被定义。我认为你被困于选择几个不好的选项,包括:
It doesn't look like they've provided a clean way to prevent the macro from being defined. I think you're stuck with choosing from several bad options, including:
-
#undef BitTest
自己 - 修改
winnt.h
标题 - 隔离您使用的代码Windows API直接插入不依赖于
BitTest<>
模板的模块
#undef BitTest
yourself- modify the
winnt.h
header - segregate your code that uses Windows APIs directly into modules that aren't dependent on your
BitTest<>
template
我确定还有其他选项 - 我只是不确定哪一个是最不讨厌的。
I'm sure there are other options - I'm just not sure sure which one is the least distasteful.
这篇关于Win32:BitTest,BitTestAndComplement,...< - 如何禁用这个垃圾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!