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
I have a number of templates that are based on BitTest<>()
Does anyone know of a simple way to disable these #defines?
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. ;)
Editorializing:
- Why couldn't Microsoft just use the _bittest itself???
- Or why couldn't they use BITTEST like every knows you should - always use all-caps for macros!
- Micr开发者_高级运维osoft is still #defining things in 2010?! WTF?
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
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.
精彩评论