Fixed VC which doesn't have INT64_C()/UINT64_C macros.
This commit is contained in:
parent
208d2bd7a8
commit
adf6629223
@ -91,23 +91,23 @@ public:
|
||||
data_.n.i64 = i64;
|
||||
if (i64 >= 0) {
|
||||
flags_ |= kNumberUint64Flag;
|
||||
if (!(static_cast<uint64_t>(i64) & UINT64_C(0xFFFFFFFF00000000)))
|
||||
if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C(0xFFFFFFFF00000000)))
|
||||
flags_ |= kUintFlag;
|
||||
if (!(static_cast<uint64_t>(i64) & UINT64_C(0xFFFFFFFF80000000)))
|
||||
if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C(0xFFFFFFFF80000000)))
|
||||
flags_ |= kIntFlag;
|
||||
}
|
||||
else if (i64 >= INT64_C(-2147483648))
|
||||
else if (i64 >= RAPIDJSON_INT64_C(-2147483648))
|
||||
flags_ |= kIntFlag;
|
||||
}
|
||||
|
||||
//! Constructor for uint64_t value.
|
||||
GenericValue(uint64_t u64) : flags_(kNumberUint64Flag) {
|
||||
data_.n.u64 = u64;
|
||||
if (!(u64 & UINT64_C(0x8000000000000000)))
|
||||
if (!(u64 & RAPIDJSON_UINT64_C(0x8000000000000000)))
|
||||
flags_ |= kInt64Flag;
|
||||
if (!(u64 & UINT64_C(0xFFFFFFFF00000000)))
|
||||
if (!(u64 & RAPIDJSON_UINT64_C(0xFFFFFFFF00000000)))
|
||||
flags_ |= kUintFlag;
|
||||
if (!(u64 & UINT64_C(0xFFFFFFFF80000000)))
|
||||
if (!(u64 & RAPIDJSON_UINT64_C(0xFFFFFFFF80000000)))
|
||||
flags_ |= kIntFlag;
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,26 @@
|
||||
// Here defines int64_t and uint64_t types in global namespace.
|
||||
// If user have their own definition, can define RAPIDJSON_NO_INT64DEFINE to disable this.
|
||||
#ifndef RAPIDJSON_NO_INT64DEFINE
|
||||
// Old Visual C++ does not have standard integer types, typedef our own.
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#ifndef RAPIDJSON_INT64_C
|
||||
#define RAPIDJSON_INT64_C(x) x##LL
|
||||
#endif
|
||||
#ifndef RAPIDJSON_UINT64_C
|
||||
#define RAPIDJSON_UINT64_C(x) x##uLL
|
||||
#endif
|
||||
#else
|
||||
// Other compilers should have this.
|
||||
#include <inttypes.h>
|
||||
#ifndef RAPIDJSON_INT64_C
|
||||
#define RAPIDJSON_INT64_C(x) INT64_C(x)
|
||||
#endif
|
||||
#ifndef RAPIDJSON_UINT64_C
|
||||
#define RAPIDJSON_UINT64_C(x) UINT64_C(x)
|
||||
#endif
|
||||
#endif // _MSC_VER
|
||||
#endif // RAPIDJSON_NO_INT64TYPEDEF
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -527,8 +527,8 @@ private:
|
||||
i64 = i;
|
||||
if (minus)
|
||||
while (s.Peek() >= '0' && s.Peek() <= '9') {
|
||||
if (i64 >= UINT64_C(922337203685477580)) // 2^63 = 9223372036854775808
|
||||
if (i64 != UINT64_C(922337203685477580) || s.Peek() > '8') {
|
||||
if (i64 >= RAPIDJSON_UINT64_C(922337203685477580)) // 2^63 = 9223372036854775808
|
||||
if (i64 != RAPIDJSON_UINT64_C(922337203685477580) || s.Peek() > '8') {
|
||||
useDouble = true;
|
||||
break;
|
||||
}
|
||||
@ -536,8 +536,8 @@ private:
|
||||
}
|
||||
else
|
||||
while (s.Peek() >= '0' && s.Peek() <= '9') {
|
||||
if (i64 >= UINT64_C(1844674407370955161)) // 2^64 - 1 = 18446744073709551615
|
||||
if (i64 != UINT64_C(1844674407370955161) || s.Peek() > '5') {
|
||||
if (i64 >= RAPIDJSON_UINT64_C(1844674407370955161)) // 2^64 - 1 = 18446744073709551615
|
||||
if (i64 != RAPIDJSON_UINT64_C(1844674407370955161) || s.Peek() > '5') {
|
||||
useDouble = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user