Commit a5ca8bee authored by ll-antn's avatar ll-antn Committed by Wouter van Oortmerssen

Fix numeric_limits<T>::max() to avoid conflict with windows.h header (#5462)

parent 09dea79a
...@@ -327,7 +327,7 @@ template<typename T> inline bool StringToNumber(const char *s, T *val) { ...@@ -327,7 +327,7 @@ template<typename T> inline bool StringToNumber(const char *s, T *val) {
int64_t i64; int64_t i64;
// The errno check isn't needed, will return MAX/MIN on overflow. // The errno check isn't needed, will return MAX/MIN on overflow.
if (StringToIntegerImpl(&i64, s, 0, false)) { if (StringToIntegerImpl(&i64, s, 0, false)) {
const int64_t max = flatbuffers::numeric_limits<T>::max(); const int64_t max = (flatbuffers::numeric_limits<T>::max)();
const int64_t min = flatbuffers::numeric_limits<T>::lowest(); const int64_t min = flatbuffers::numeric_limits<T>::lowest();
if (i64 > max) { if (i64 > max) {
*val = static_cast<T>(max); *val = static_cast<T>(max);
...@@ -365,7 +365,7 @@ inline bool StringToNumber<uint64_t>(const char *str, uint64_t *val) { ...@@ -365,7 +365,7 @@ inline bool StringToNumber<uint64_t>(const char *str, uint64_t *val) {
if (*s == '-') { if (*s == '-') {
// For unsigned types return the max to distinguish from // For unsigned types return the max to distinguish from
// "no conversion can be performed". // "no conversion can be performed".
*val = flatbuffers::numeric_limits<uint64_t>::max(); *val = (flatbuffers::numeric_limits<uint64_t>::max)();
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment