Win32: BitTest, BitTestAndComplement, ... <- How to disable this garbage?

WinNT.h contains the following lines in the VS2008 SP1 installation:

 #define BitTest _bittest #define BitTestAndComplement _bittestandcomplement #define BitTestAndSet _bittestandset #define BitTestAndReset _bittestandreset #define InterlockedBitTestAndSet _interlockedbittestandset #define InterlockedBitTestAndReset _interlockedbittestandreset 

I have several BitTest based templates <> ()

Does anyone know an easy way to disable these #defines?

Often, MS does provide the #define XXX character, which, if defined, will disable some of the violation of their header - for example, NOMINMAX.

I could not find such a solution to the above problem.

If you share Microsoft’s frustration with many dubious choices, read on. If not, stay here.;)

Editorializing:

  • Why can't Microsoft use _bittest itself ???
  • Or why they cannot use BITTEST, as everyone knows you should - always use all caps for macros!
  • Microsoft is still #defining things in 2010 ?! WTF?
+2
source share
1 answer

Unfortunately, Microsoft believes that their APIs use macros for names, as they do so for 95% or more of their APIs to make them work "transparently" for the ANSI and Unicode APIs.

They don't seem to provide a clean way to prevent macro definition. I think you are stuck with a selection of several bad options, including:

  • #undef BitTest yourself
  • change winnt.h header
  • split your code that uses the Windows API directly into modules that are independent of your BitTest<> template BitTest<>

I'm sure there are other options - I'm just not sure which one is the least unpleasant.

+1
source

Source: https://habr.com/ru/post/1301827/


All Articles