Fixed conflict with windows min and max

If windows.h is included before spirv_common.hpp without NOMINMAX being defined the windows min and max macros will conflict with the STL numeric limits functions.
This commit is contained in:
Frank McCoy 2024-01-22 00:49:18 -08:00 committed by GitHub
parent b82536766d
commit e07956776d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -220,7 +220,7 @@ static inline std::string convert_to_string(int32_t value)
// INT_MIN is ... special on some backends. If we use a decimal literal, and negate it, we
// could accidentally promote the literal to long first, then negate.
// To workaround it, emit int(0x80000000) instead.
if (value == std::numeric_limits<int32_t>::min())
if (value == (std::numeric_limits<int32_t>::min)())
return "int(0x80000000)";
else
return std::to_string(value);
@ -231,7 +231,7 @@ static inline std::string convert_to_string(int64_t value, const std::string &in
// INT64_MIN is ... special on some backends.
// If we use a decimal literal, and negate it, we might overflow the representable numbers.
// To workaround it, emit int(0x80000000) instead.
if (value == std::numeric_limits<int64_t>::min())
if (value == (std::numeric_limits<int64_t>::min)())
return join(int64_type, "(0x8000000000000000u", (long_long_literal_suffix ? "ll" : "l"), ")");
else
return std::to_string(value) + (long_long_literal_suffix ? "ll" : "l");