From ae8dc102518d2047e42296b0326a27c8f4f0e65b Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 6 Nov 2014 21:23:41 -0500 Subject: [PATCH 1/2] Make 64-bit int work with 'long int' and 'int64_t' for 64 bit builds (Issue #64) --- include/json/config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/json/config.h b/include/json/config.h index afd3a4560..85b53b08b 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -87,6 +87,7 @@ #define JSONCPP_DEPRECATED(message) #endif // if !defined(JSONCPP_DEPRECATED) +#include namespace Json { typedef int Int; typedef unsigned int UInt; @@ -100,8 +101,8 @@ typedef unsigned int LargestUInt; typedef __int64 Int64; typedef unsigned __int64 UInt64; #else // if defined(_MSC_VER) // Other platforms, use long long -typedef long long int Int64; -typedef unsigned long long int UInt64; +typedef int64_t Int64; +typedef uint64_t UInt64; #endif // if defined(_MSC_VER) typedef Int64 LargestInt; typedef UInt64 LargestUInt; From 1a7e76266a4c1345ac87261cd9f9705fd14a1798 Mon Sep 17 00:00:00 2001 From: David Jones Date: Sat, 8 Nov 2014 21:02:08 -0500 Subject: [PATCH 2/2] Only use fix-width types for C++11 (Issue #64) --- include/json/config.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/json/config.h b/include/json/config.h index 85b53b08b..8d947b2b2 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -87,7 +87,7 @@ #define JSONCPP_DEPRECATED(message) #endif // if !defined(JSONCPP_DEPRECATED) -#include +#include namespace Json { typedef int Int; typedef unsigned int UInt; @@ -100,9 +100,12 @@ typedef unsigned int LargestUInt; #if defined(_MSC_VER) // Microsoft Visual Studio typedef __int64 Int64; typedef unsigned __int64 UInt64; -#else // if defined(_MSC_VER) // Other platforms, use long long +#elif __cplusplus >= 201103L // Using C++11 typedef int64_t Int64; typedef uint64_t UInt64; +#else // Other platforms, use long long +typedef long long Int64; +typedef unsigned long long Uint64; #endif // if defined(_MSC_VER) typedef Int64 LargestInt; typedef UInt64 LargestUInt;