better-enums icon indicating copy to clipboard operation
better-enums copied to clipboard

Microsoft Visual C++ Compiler warning C4800 if using bool as the underlying type of a Better Enum

Open FlorianWolters opened this issue 8 years ago • 0 comments

Declaring a Better Enum with a underlying type of bool results in a C4800 compiler warning (tested with both MSVC 12.0 + MSVC 14.0, using /W3).

Source code to reproduce the issue:

BETTER_ENUM(Boolean, bool, TRUE = true, FALSE = false)

Compiler output (in German):

"example::Boolean::_enumerated": Variable wird auf booleschen Wert ("True" oder "False") gesetzt (Auswirkungen auf Leistungsverhalten möglich)

Suggestion

I think Better Enums should work the same as a built-in enum class. The following source code does not raise a compiler warning:

enum class Boolean : bool {
  TRUE = true,
  FALSE = false
};

FlorianWolters avatar Jan 23 '17 17:01 FlorianWolters