diff --git a/src/util/enum_operators.h b/src/util/enum_operators.h index ec3b7f5ee5f..3a2bb53c060 100644 --- a/src/util/enum_operators.h +++ b/src/util/enum_operators.h @@ -23,20 +23,26 @@ #ifdef __cplusplus +#include + // some enum helpers #define MESA_DEFINE_CPP_ENUM_BINARY_OPERATOR(Enum, op) \ extern "C++" { \ static inline \ Enum operator op (Enum a, Enum b) \ { \ - uint64_t ua = a, ub = b; \ + using IntType = std::underlying_type_t; \ + IntType ua = static_cast(a); \ + IntType ub = static_cast(b); \ return static_cast(ua op ub); \ } \ \ static inline \ Enum& operator op##= (Enum &a, Enum b) \ { \ - uint64_t ua = a, ub = b; \ + using IntType = std::underlying_type_t; \ + IntType ua = static_cast(a); \ + IntType ub = static_cast(b); \ ua op##= ub; \ a = static_cast(ua); \ return a; \ @@ -48,7 +54,8 @@ extern "C++" { \ static inline \ Enum operator op (Enum a) \ { \ - uint64_t ua = a; \ + using IntType = std::underlying_type_t; \ + IntType ua = static_cast(a); \ return static_cast(op ua); \ } \ }