Commit adf66292 authored by Milo Yip's avatar Milo Yip

Fixed VC which doesn't have INT64_C()/UINT64_C macros.

parent 208d2bd7
......@@ -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;
#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;
}
......
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