Skip to content

Commit 076a00b

Browse files
committed
fixed compiler warnings in json_value.cpp dealing with size_t.
Used stdint.h to define standard integers instead of the homegrown version in include/json/config.h
1 parent 59d6d09 commit 076a00b

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

include/json/config.h

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,25 @@
7676
#define JSONCPP_DEPRECATED(message)
7777
#endif // if !defined(JSONCPP_DEPRECATED)
7878

79+
// Use the mostly standard stdint.h to define
80+
// integer types.
81+
#ifndef JSONCPP_USE_STDINT_H
82+
#define JSONCPP_USE_STDINT_H 1
83+
#endif
84+
85+
86+
#if JSONCPP_USE_STDINT_H
87+
#include <stdint.h>
88+
namespace Json {
89+
typedef int32_t Int;
90+
typedef uint32_t UInt;
91+
typedef int64_t Int64;
92+
typedef uint64_t UInt64;
93+
} // end namespace Json
94+
#else
7995
namespace Json {
8096
typedef int Int;
8197
typedef unsigned int UInt;
82-
#if defined(JSON_NO_INT64)
83-
typedef int LargestInt;
84-
typedef unsigned int LargestUInt;
85-
#undef JSON_HAS_INT64
86-
#else // if defined(JSON_NO_INT64)
8798
// For Microsoft Visual use specific types as long long is not supported
8899
#if defined(_MSC_VER) // Microsoft Visual Studio
89100
typedef __int64 Int64;
@@ -92,10 +103,20 @@ typedef unsigned __int64 UInt64;
92103
typedef long long int Int64;
93104
typedef unsigned long long int UInt64;
94105
#endif // if defined(_MSC_VER)
95-
typedef Int64 LargestInt;
96-
typedef UInt64 LargestUInt;
106+
} // end namespace Json
107+
#endif
108+
109+
namespace Json
110+
{
111+
#if defined(JSON_NO_INT64)
112+
typedef Int LargestInt;
113+
typedef UInt LargestUInt;
114+
#undef JSON_HAS_INT64
115+
#else
116+
typedef Int64 LargestInt;
117+
typedef UInt64 LargestUInt;
97118
#define JSON_HAS_INT64
98-
#endif // if defined(JSON_NO_INT64)
119+
#endif
99120
} // end namespace Json
100121

101122
#endif // JSON_CONFIG_H_INCLUDED

src/lib_json/json_value.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);
5252
const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
5353

5454
/// Unknown size marker
55-
static const unsigned int unknown = (unsigned)-1;
55+
static const size_t unknown = (size_t)-1;
5656

5757
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
5858
template <typename T, typename U>
@@ -82,9 +82,9 @@ static inline bool InRange(double d, T min, U max) {
8282
* @return Pointer on the duplicate instance of string.
8383
*/
8484
static inline char* duplicateStringValue(const char* value,
85-
unsigned int length = unknown) {
85+
size_t length = unknown) {
8686
if (length == unknown)
87-
length = (unsigned int)strlen(value);
87+
length = strlen(value);
8888

8989
// Avoid an integer overflow in the call to malloc below by limiting length
9090
// to a sane value.

0 commit comments

Comments
 (0)