Commit e440b695 authored by Milo Yip's avatar Milo Yip

Merge pull request #62 from pah/fixes/msvc

Fixes and cleanups for MSVC 
parents 63d05434 6d558362
......@@ -64,7 +64,7 @@ solution "test"
defines { "_CRT_SECURE_NO_WARNINGS" }
configuration "gmake"
buildoptions "-msse4.2 -Werror -Wall -Wextra -Wswitch-default"
buildoptions "-msse4.2 -Werror -Wall -Wextra"
project "gtest"
kind "StaticLib"
......@@ -87,7 +87,7 @@ solution "test"
kind "ConsoleApp"
if _ACTION == "gmake" then
buildoptions "-Weffc++"
buildoptions "-Weffc++ -Wswitch-default"
end
files {
......
......@@ -501,7 +501,7 @@ public:
\see GenericStringRef, operator=(T)
*/
GenericValue& operator=(StringRefType str) {
return (*this).template operator=<StringRefType>(str);
return (*this).operator=<StringRefType>(str);
}
//! Assignment with primitive types.
......
......@@ -3,7 +3,10 @@
#include "rapidjson.h"
#ifdef __GNUC__
#ifdef _MSC_VER
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4244) // conversion from 'type1' to 'type2', possible loss of data
#elif defined(__GNUC__)
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif
......@@ -529,7 +532,7 @@ struct Transcoder<Encoding, Encoding> {
} // namespace rapidjson
#ifdef __GNUC__
#if defined(__GNUC__) || defined(_MSV_VER)
RAPIDJSON_DIAG_POP
#endif
......
......@@ -13,8 +13,7 @@ namespace internal {
template <typename Ch>
inline SizeType StrLen(const Ch* s) {
const Ch* p = s;
while (*p != '\0')
++p;
while (*p) ++p;
return SizeType(p - s);
}
......
......@@ -9,6 +9,10 @@
#include "internal/pow10.h"
#include "internal/stack.h"
#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER)
#include <intrin.h>
#pragma intrinsic(_BitScanForward)
#endif
#ifdef RAPIDJSON_SSE42
#include <nmmintrin.h>
#elif defined(RAPIDJSON_SSE2)
......@@ -16,8 +20,8 @@
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
#endif
#ifndef RAPIDJSON_PARSE_ERROR_NORETURN
......@@ -769,7 +773,7 @@ typedef GenericReader<UTF8<>, UTF8<> > Reader;
} // namespace rapidjson
#ifdef _MSC_VER
#pragma warning(pop)
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_READER_H_
......@@ -8,8 +8,8 @@
#include <new> // placement new
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
#endif
namespace rapidjson {
......@@ -185,7 +185,7 @@ protected:
char buffer[10];
char *p = buffer;
do {
*p++ = (u % 10) + '0';
*p++ = char(u % 10) + '0';
u /= 10;
} while (u > 0);
......@@ -306,7 +306,7 @@ private:
} // namespace rapidjson
#ifdef _MSC_VER
#pragma warning(pop)
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_RAPIDJSON_H_
......@@ -242,7 +242,7 @@ TEST_F(RapidJson, PrettyWriter_StringBuffer) {
TEST_F(RapidJson, internal_Pow10) {
double sum = 0;
for (size_t i = 0; i < kTrialCount * kTrialCount; i++)
sum += internal::Pow10(i & 255);
sum += internal::Pow10(int(i & 255));
EXPECT_GT(sum, 0.0);
}
......
......@@ -27,10 +27,10 @@
#endif
template <typename Ch>
inline size_t StrLen(const Ch* s) {
inline unsigned StrLen(const Ch* s) {
const Ch* p = s;
while (*p) p++;
return p - s;
return unsigned(p - s);
}
template<typename Ch>
......
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