diff --git a/distr/flecs.h b/distr/flecs.h index cface0bacd..80c92d83db 100644 --- a/distr/flecs.h +++ b/distr/flecs.h @@ -18053,8 +18053,10 @@ struct enum_reflection { static constexpr U each_enum(Args... args) { return each_mask_range(each_enum_range<0, Value>(0, args...), args...); } - - static const U high_bit = static_cast(1) << (sizeof(U) * 8 - 1); + /* to avoid warnings with bit manipulation, calculate the high bit with an + unsigned type of the same size: */ + using UU = typename std::make_unsigned::type; + static const U high_bit = static_cast(static_cast(1) << (sizeof(UU) * 8 - 1)); }; /** Enumeration type data */ diff --git a/include/flecs/addons/cpp/utils/enum.hpp b/include/flecs/addons/cpp/utils/enum.hpp index 9f1f53c018..cac54df373 100644 --- a/include/flecs/addons/cpp/utils/enum.hpp +++ b/include/flecs/addons/cpp/utils/enum.hpp @@ -260,8 +260,10 @@ struct enum_reflection { static constexpr U each_enum(Args... args) { return each_mask_range(each_enum_range<0, Value>(0, args...), args...); } - - static const U high_bit = static_cast(1) << (sizeof(U) * 8 - 1); + /* to avoid warnings with bit manipulation, calculate the high bit with an + unsigned type of the same size: */ + using UU = typename std::make_unsigned::type; + static const U high_bit = static_cast(static_cast(1) << (sizeof(UU) * 8 - 1)); }; /** Enumeration type data */