Updated definition of _BITMASK_OPS in VS2022 leads to compile error

I am upgrading C++ code from VS2019 to VS2022. My code references _BITMASK_OPS that lives in <type_traits> under MSVC provided by visual studio.
(C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\type_traits)

In VS2019 the define is:

#define _BITMASK_OPS(_BITMASK)

In VS2022 it changed to:

#define _BITMASK_OPS(_MAYBE_EXPORT, _BITMASK)

However I cannot find any information, or any other references, to _MAYBE_EXPORT, other than immediate usage of it right below the define.

Previous usage looks like this and compiles in VS2019:

enum class launch_proxy
  {
  async = 0x1,
  deferred = 0x2
  };

_BITMASK_OPS (launch_proxy)

Any ideas?

  • 7

    _BITMASK_OPS is an implementation detail not meant to used in your code. If you do use it you will face just this problem: in the next version it might be gone or changed

    – 

  • anyhow, if _MAYBE_EXPORT is not used anywhere as you say you can simply pass a dummy argument, but the real fix would be to no use the macro

    – 




  • or do you refer to the macros definition with “right below the define” ? You dont find it anywhere else because its just the name of an argument which can be arbitrary and only has meaning inside the funciton

    – 

  • 3

    this is an xy problem. Rather than trying to fix the usage of the macro you should find a way to not use it

    – 




  • _MAYBE_EXPORT is used to add the keyword export when compiling with modules support. That feature didn’t exist in 2019.

    – 




Leave a Comment