Supressed warnings on MSVC.
This commit is contained in:
Takatoshi Kondo 2015-01-15 01:19:01 +09:00
parent a84f444ce2
commit 7f48ddc85e
10 changed files with 97 additions and 97 deletions

View File

@ -215,9 +215,9 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" ST
ENDIF () ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /wd4290 /wd4309" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE () ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4309") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
ENDIF () ENDIF ()
ENDIF () ENDIF ()

View File

@ -161,21 +161,21 @@ public:
void clear(); void clear();
void swap(zone& o); void swap(zone& o);
static void* operator new(std::size_t size) throw(std::bad_alloc) static void* operator new(std::size_t size)
{ {
void* p = ::malloc(size); void* p = ::malloc(size);
if (!p) throw std::bad_alloc(); if (!p) throw std::bad_alloc();
return p; return p;
} }
static void operator delete(void *p) throw() static void operator delete(void *p) /* throw() */
{ {
::free(p); ::free(p);
} }
static void* operator new(std::size_t size, void* place) throw() static void* operator new(std::size_t size, void* place) /* throw() */
{ {
return ::operator new(size, place); return ::operator new(size, place);
} }
static void operator delete(void* p, void* place) throw() static void operator delete(void* p, void* place) /* throw() */
{ {
::operator delete(p, place); ::operator delete(p, place);
} }

View File

@ -161,21 +161,21 @@ public:
void clear(); void clear();
void swap(zone& o); void swap(zone& o);
static void* operator new(std::size_t size) throw(std::bad_alloc) static void* operator new(std::size_t size)
{ {
void* p = ::malloc(size); void* p = ::malloc(size);
if (!p) throw std::bad_alloc(); if (!p) throw std::bad_alloc();
return p; return p;
} }
static void operator delete(void *p) throw() static void operator delete(void *p) /* throw() */
{ {
::free(p); ::free(p);
} }
static void* operator new(std::size_t size, void* place) throw() static void* operator new(std::size_t size, void* place) /* throw() */
{ {
return ::operator new(size, place); return ::operator new(size, place);
} }
static void operator delete(void* p, void* place) throw() static void operator delete(void* p, void* place) /* throw() */
{ {
::operator delete(p, place); ::operator delete(p, place);
} }

View File

@ -221,7 +221,7 @@ inline packer<Stream>& packer<Stream>::pack_int64(int64_t d)
template <typename Stream> template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_uint8(uint8_t d) inline packer<Stream>& packer<Stream>::pack_fix_uint8(uint8_t d)
{ {
char buf[2] = {static_cast<char>(0xcc), take8_8(d)}; char buf[2] = {static_cast<char>(0xccu), take8_8(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
return *this; return *this;
} }
@ -230,7 +230,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_uint16(uint16_t d) inline packer<Stream>& packer<Stream>::pack_fix_uint16(uint16_t d)
{ {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], d); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], d);
append_buffer(buf, 3); append_buffer(buf, 3);
return *this; return *this;
} }
@ -239,7 +239,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_uint32(uint32_t d) inline packer<Stream>& packer<Stream>::pack_fix_uint32(uint32_t d)
{ {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], d); buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], d);
append_buffer(buf, 5); append_buffer(buf, 5);
return *this; return *this;
} }
@ -248,7 +248,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d) inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d)
{ {
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d); buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
append_buffer(buf, 9); append_buffer(buf, 9);
return *this; return *this;
} }
@ -256,7 +256,7 @@ inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d)
template <typename Stream> template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int8(int8_t d) inline packer<Stream>& packer<Stream>::pack_fix_int8(int8_t d)
{ {
char buf[2] = {static_cast<char>(0xd0), take8_8(d)}; char buf[2] = {static_cast<char>(0xd0u), take8_8(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
return *this; return *this;
} }
@ -265,7 +265,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int16(int16_t d) inline packer<Stream>& packer<Stream>::pack_fix_int16(int16_t d)
{ {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], d); buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], d);
append_buffer(buf, 3); append_buffer(buf, 3);
return *this; return *this;
} }
@ -274,7 +274,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int32(int32_t d) inline packer<Stream>& packer<Stream>::pack_fix_int32(int32_t d)
{ {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], d); buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], d);
append_buffer(buf, 5); append_buffer(buf, 5);
return *this; return *this;
} }
@ -283,7 +283,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int64(int64_t d) inline packer<Stream>& packer<Stream>::pack_fix_int64(int64_t d)
{ {
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xd3); _msgpack_store64(&buf[1], d); buf[0] = static_cast<char>(0xd3u); _msgpack_store64(&buf[1], d);
append_buffer(buf, 9); append_buffer(buf, 9);
return *this; return *this;
} }
@ -590,7 +590,7 @@ inline packer<Stream>& packer<Stream>::pack_float(float d)
union { float f; uint32_t i; } mem; union { float f; uint32_t i; } mem;
mem.f = d; mem.f = d;
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xca); _msgpack_store32(&buf[1], mem.i); buf[0] = static_cast<char>(0xcau); _msgpack_store32(&buf[1], mem.i);
append_buffer(buf, 5); append_buffer(buf, 5);
return *this; return *this;
} }
@ -601,7 +601,7 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
union { double f; uint64_t i; } mem; union { double f; uint64_t i; } mem;
mem.f = d; mem.f = d;
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xcb); buf[0] = static_cast<char>(0xcbu);
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi #if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
// https://github.com/msgpack/msgpack-perl/pull/1 // https://github.com/msgpack/msgpack-perl/pull/1
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL); mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
@ -615,7 +615,7 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
template <typename Stream> template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_nil() inline packer<Stream>& packer<Stream>::pack_nil()
{ {
const char d = static_cast<char>(0xc0); const char d = static_cast<char>(0xc0u);
append_buffer(&d, 1); append_buffer(&d, 1);
return *this; return *this;
} }
@ -623,7 +623,7 @@ inline packer<Stream>& packer<Stream>::pack_nil()
template <typename Stream> template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_true() inline packer<Stream>& packer<Stream>::pack_true()
{ {
const char d = static_cast<char>(0xc3); const char d = static_cast<char>(0xc3u);
append_buffer(&d, 1); append_buffer(&d, 1);
return *this; return *this;
} }
@ -631,7 +631,7 @@ inline packer<Stream>& packer<Stream>::pack_true()
template <typename Stream> template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_false() inline packer<Stream>& packer<Stream>::pack_false()
{ {
const char d = static_cast<char>(0xc2); const char d = static_cast<char>(0xc2u);
append_buffer(&d, 1); append_buffer(&d, 1);
return *this; return *this;
} }
@ -641,15 +641,15 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_array(size_t n) inline packer<Stream>& packer<Stream>::pack_array(size_t n)
{ {
if(n < 16) { if(n < 16) {
char d = static_cast<char>(0x90 | n); char d = static_cast<char>(0x90u | n);
append_buffer(&d, 1); append_buffer(&d, 1);
} else if(n < 65536) { } else if(n < 65536) {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xdc); _msgpack_store16(&buf[1], static_cast<uint16_t>(n)); buf[0] = static_cast<char>(0xdcu); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xdd); _msgpack_store32(&buf[1], static_cast<uint32_t>(n)); buf[0] = static_cast<char>(0xddu); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
return *this; return *this;
@ -659,16 +659,16 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_map(size_t n) inline packer<Stream>& packer<Stream>::pack_map(size_t n)
{ {
if(n < 16) { if(n < 16) {
unsigned char d = 0x80 | n; unsigned char d = 0x80u | n;
char buf = take8_8(d); char buf = take8_8(d);
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else if(n < 65536) { } else if(n < 65536) {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xde); _msgpack_store16(&buf[1], static_cast<uint16_t>(n)); buf[0] = static_cast<char>(0xdeu); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xdf); _msgpack_store32(&buf[1], static_cast<uint32_t>(n)); buf[0] = static_cast<char>(0xdfu); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
return *this; return *this;
@ -678,20 +678,20 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_str(size_t l) inline packer<Stream>& packer<Stream>::pack_str(size_t l)
{ {
if(l < 32) { if(l < 32) {
unsigned char d = 0xa0 | static_cast<uint8_t>(l); unsigned char d = 0xa0u | static_cast<uint8_t>(l);
char buf = take8_8(d); char buf = take8_8(d);
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else if(l < 256) { } else if(l < 256) {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd9); buf[1] = static_cast<uint8_t>(l); buf[0] = static_cast<char>(0xd9u); buf[1] = static_cast<uint8_t>(l);
append_buffer(buf, 2); append_buffer(buf, 2);
} else if(l < 65536) { } else if(l < 65536) {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xda); _msgpack_store16(&buf[1], static_cast<uint16_t>(l)); buf[0] = static_cast<char>(0xdau); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xdb); _msgpack_store32(&buf[1], static_cast<uint32_t>(l)); buf[0] = static_cast<char>(0xdbu); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
return *this; return *this;
@ -709,15 +709,15 @@ inline packer<Stream>& packer<Stream>::pack_bin(size_t l)
{ {
if(l < 256) { if(l < 256) {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xc4); buf[1] = static_cast<uint8_t>(l); buf[0] = static_cast<char>(0xc4u); buf[1] = static_cast<uint8_t>(l);
append_buffer(buf, 2); append_buffer(buf, 2);
} else if(l < 65536) { } else if(l < 65536) {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xc5); _msgpack_store16(&buf[1], static_cast<uint16_t>(l)); buf[0] = static_cast<char>(0xc5u); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xc6); _msgpack_store32(&buf[1], static_cast<uint32_t>(l)); buf[0] = static_cast<char>(0xc6u); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
return *this; return *this;
@ -736,50 +736,50 @@ inline packer<Stream>& packer<Stream>::pack_ext(size_t l, int8_t type)
switch(l) { switch(l) {
case 1: { case 1: {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd4); buf[0] = static_cast<char>(0xd4u);
buf[1] = static_cast<char>(type); buf[1] = static_cast<char>(type);
append_buffer(buf, 2); append_buffer(buf, 2);
} break; } break;
case 2: { case 2: {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd5); buf[0] = static_cast<char>(0xd5u);
buf[1] = static_cast<char>(type); buf[1] = static_cast<char>(type);
append_buffer(buf, 2); append_buffer(buf, 2);
} break; } break;
case 4: { case 4: {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd6); buf[0] = static_cast<char>(0xd6u);
buf[1] = static_cast<char>(type); buf[1] = static_cast<char>(type);
append_buffer(buf, 2); append_buffer(buf, 2);
} break; } break;
case 8: { case 8: {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd7); buf[0] = static_cast<char>(0xd7u);
buf[1] = static_cast<char>(type); buf[1] = static_cast<char>(type);
append_buffer(buf, 2); append_buffer(buf, 2);
} break; } break;
case 16: { case 16: {
char buf[2]; char buf[2];
buf[0] = static_cast<char>(0xd8); buf[0] = static_cast<char>(0xd8u);
buf[1] = static_cast<char>(type); buf[1] = static_cast<char>(type);
append_buffer(buf, 2); append_buffer(buf, 2);
} break; } break;
default: default:
if(l < 256) { if(l < 256) {
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xc7); buf[0] = static_cast<char>(0xc7u);
buf[1] = static_cast<char>(l); buf[1] = static_cast<char>(l);
buf[2] = static_cast<char>(type); buf[2] = static_cast<char>(type);
append_buffer(buf, 3); append_buffer(buf, 3);
} else if(l < 65536) { } else if(l < 65536) {
char buf[4]; char buf[4];
buf[0] = static_cast<char>(0xc8); buf[0] = static_cast<char>(0xc8u);
_msgpack_store16(&buf[1], static_cast<uint16_t>(l)); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
buf[3] = static_cast<char>(type); buf[3] = static_cast<char>(type);
append_buffer(buf, 4); append_buffer(buf, 4);
} else { } else {
char buf[6]; char buf[6];
buf[0] = static_cast<char>(0xc9); buf[0] = static_cast<char>(0xc9u);
_msgpack_store32(&buf[1], static_cast<uint32_t>(l)); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
buf[5] = static_cast<char>(type); buf[5] = static_cast<char>(type);
append_buffer(buf, 6); append_buffer(buf, 6);
@ -806,7 +806,7 @@ inline void packer<Stream>::pack_imp_uint8(T d)
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else { } else {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_8(d)}; char buf[2] = {static_cast<char>(0xccu), take8_8(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} }
@ -821,12 +821,12 @@ inline void packer<Stream>::pack_imp_uint16(T d)
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else if(d < (1<<8)) { } else if(d < (1<<8)) {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_16(d)}; char buf[2] = {static_cast<char>(0xccu), take8_16(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} else { } else {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} }
} }
@ -842,19 +842,19 @@ inline void packer<Stream>::pack_imp_uint32(T d)
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else { } else {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_32(d)}; char buf[2] = {static_cast<char>(0xccu), take8_32(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} else { } else {
if(d < (1<<16)) { if(d < (1<<16)) {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
/* unsigned 32 */ /* unsigned 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d)); buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
} }
@ -871,24 +871,24 @@ inline void packer<Stream>::pack_imp_uint64(T d)
append_buffer(&buf, 1); append_buffer(&buf, 1);
} else { } else {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_64(d)}; char buf[2] = {static_cast<char>(0xccu), take8_64(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} else { } else {
if(d < (1ULL<<16)) { if(d < (1ULL<<16)) {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else if(d < (1ULL<<32)) { } else if(d < (1ULL<<32)) {
/* unsigned 32 */ /* unsigned 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d)); buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} else { } else {
/* unsigned 64 */ /* unsigned 64 */
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d); buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
append_buffer(buf, 9); append_buffer(buf, 9);
} }
} }
@ -900,7 +900,7 @@ inline void packer<Stream>::pack_imp_int8(T d)
{ {
if(d < -(1<<5)) { if(d < -(1<<5)) {
/* signed 8 */ /* signed 8 */
char buf[2] = {static_cast<char>(0xd0), take8_8(d)}; char buf[2] = {static_cast<char>(0xd0u), take8_8(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} else { } else {
/* fixnum */ /* fixnum */
@ -917,11 +917,11 @@ inline void packer<Stream>::pack_imp_int16(T d)
if(d < -(1<<7)) { if(d < -(1<<7)) {
/* signed 16 */ /* signed 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d)); buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
/* signed 8 */ /* signed 8 */
char buf[2] = {static_cast<char>(0xd0), take8_16(d)}; char buf[2] = {static_cast<char>(0xd0u), take8_16(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} else if(d < (1<<7)) { } else if(d < (1<<7)) {
@ -931,12 +931,12 @@ inline void packer<Stream>::pack_imp_int16(T d)
} else { } else {
if(d < (1<<8)) { if(d < (1<<8)) {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_16(d)}; char buf[2] = {static_cast<char>(0xccu), take8_16(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} else { } else {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} }
} }
@ -950,16 +950,16 @@ inline void packer<Stream>::pack_imp_int32(T d)
if(d < -(1<<15)) { if(d < -(1<<15)) {
/* signed 32 */ /* signed 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], static_cast<int32_t>(d)); buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} else if(d < -(1<<7)) { } else if(d < -(1<<7)) {
/* signed 16 */ /* signed 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d)); buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
/* signed 8 */ /* signed 8 */
char buf[2] = { static_cast<char>(0xd0), take8_32(d)}; char buf[2] = { static_cast<char>(0xd0u), take8_32(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} else if(d < (1<<7)) { } else if(d < (1<<7)) {
@ -969,17 +969,17 @@ inline void packer<Stream>::pack_imp_int32(T d)
} else { } else {
if(d < (1<<8)) { if(d < (1<<8)) {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = { static_cast<char>(0xcc), take8_32(d)}; char buf[2] = { static_cast<char>(0xccu), take8_32(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} else if(d < (1<<16)) { } else if(d < (1<<16)) {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
/* unsigned 32 */ /* unsigned 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d)); buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
} }
@ -994,23 +994,23 @@ inline void packer<Stream>::pack_imp_int64(T d)
if(d < -(1LL<<31)) { if(d < -(1LL<<31)) {
/* signed 64 */ /* signed 64 */
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xd3); _msgpack_store64(&buf[1], d); buf[0] = static_cast<char>(0xd3u); _msgpack_store64(&buf[1], d);
append_buffer(buf, 9); append_buffer(buf, 9);
} else { } else {
/* signed 32 */ /* signed 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], static_cast<int32_t>(d)); buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} }
} else { } else {
if(d < -(1<<7)) { if(d < -(1<<7)) {
/* signed 16 */ /* signed 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d)); buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} else { } else {
/* signed 8 */ /* signed 8 */
char buf[2] = {static_cast<char>(0xd0), take8_64(d)}; char buf[2] = {static_cast<char>(0xd0u), take8_64(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} }
} }
@ -1022,24 +1022,24 @@ inline void packer<Stream>::pack_imp_int64(T d)
if(d < (1LL<<16)) { if(d < (1LL<<16)) {
if(d < (1<<8)) { if(d < (1<<8)) {
/* unsigned 8 */ /* unsigned 8 */
char buf[2] = {static_cast<char>(0xcc), take8_64(d)}; char buf[2] = {static_cast<char>(0xccu), take8_64(d)};
append_buffer(buf, 2); append_buffer(buf, 2);
} else { } else {
/* unsigned 16 */ /* unsigned 16 */
char buf[3]; char buf[3];
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d)); buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
append_buffer(buf, 3); append_buffer(buf, 3);
} }
} else { } else {
if(d < (1LL<<32)) { if(d < (1LL<<32)) {
/* unsigned 32 */ /* unsigned 32 */
char buf[5]; char buf[5];
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d)); buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
append_buffer(buf, 5); append_buffer(buf, 5);
} else { } else {
/* unsigned 64 */ /* unsigned 64 */
char buf[9]; char buf[9];
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d); buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
append_buffer(buf, 9); append_buffer(buf, 9);
} }
} }

View File

@ -56,9 +56,9 @@ FOREACH (source_file ${check_PROGRAMS})
ENDIF () ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /wd4290 /wd4309" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE () ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4309") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
ENDIF () ENDIF ()
ENDIF () ENDIF ()
ENDFOREACH () ENDFOREACH ()

View File

@ -218,12 +218,12 @@ TEST(limit, unpack_ext_over_32_bit)
{ {
if (sizeof(std::size_t) == 4) { if (sizeof(std::size_t) == 4) {
char const buf [] = { char const buf [] = {
static_cast<char>(0xc9), static_cast<char>(0xc9u),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0x01), static_cast<char>(0x01u),
}; };
try { try {
msgpack::unpacked unp; msgpack::unpacked unp;
@ -244,12 +244,12 @@ TEST(limit, unpack_ext_no_over_64_bit)
{ {
if (sizeof(std::size_t) == 8) { if (sizeof(std::size_t) == 8) {
char const buf [] = { char const buf [] = {
static_cast<char>(0xc9), static_cast<char>(0xc9u),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0xff), static_cast<char>(0xffu),
static_cast<char>(0x01), static_cast<char>(0x01u),
}; };
try { try {
msgpack::unpacked unp; msgpack::unpacked unp;

View File

@ -139,11 +139,11 @@ TEST(object_with_zone, unsigned_long_long)
// float // float
TEST(object_with_zone, float) TEST(object_with_zone, float)
{ {
float v = 1.23; float v = 1.23f;
msgpack::zone z; msgpack::zone z;
msgpack::object obj(v, z); msgpack::object obj(v, z);
EXPECT_TRUE(fabs(obj.as<float>() - v) <= kEPS); EXPECT_TRUE(fabs(obj.as<float>() - v) <= kEPS);
v = 4.56; v = 4.56f;
EXPECT_TRUE(fabs(obj.as<float>() - static_cast<float>(1.23)) <= kEPS); EXPECT_TRUE(fabs(obj.as<float>() - static_cast<float>(1.23)) <= kEPS);
} }

View File

@ -40,29 +40,29 @@ TEST(unpack, sequence)
msgpack_packer_free(pk); msgpack_packer_free(pk);
bool success; msgpack_unpack_return success;
size_t offset = 0; size_t offset = 0;
msgpack_unpacked msg; msgpack_unpacked msg;
msgpack_unpacked_init(&msg); msgpack_unpacked_init(&msg);
success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset); success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset);
EXPECT_TRUE(success); EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, success);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type); EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type);
EXPECT_EQ(1, msg.data.via.u64); EXPECT_EQ(1, msg.data.via.u64);
success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset); success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset);
EXPECT_TRUE(success); EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, success);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type); EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type);
EXPECT_EQ(2, msg.data.via.u64); EXPECT_EQ(2, msg.data.via.u64);
success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset); success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset);
EXPECT_TRUE(success); EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, success);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type); EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, msg.data.type);
EXPECT_EQ(3, msg.data.via.u64); EXPECT_EQ(3, msg.data.via.u64);
success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset); success = msgpack_unpack_next(&msg, sbuf->data, sbuf->size, &offset);
EXPECT_FALSE(success); EXPECT_EQ(MSGPACK_UNPACK_CONTINUE, success);
msgpack_sbuffer_free(sbuf); msgpack_sbuffer_free(sbuf);
msgpack_unpacked_destroy(&msg); msgpack_unpacked_destroy(&msg);

View File

@ -23,7 +23,7 @@ TEST(streaming, basic)
EXPECT_EQ(0, msgpack_pack_bin(pk, 8)); EXPECT_EQ(0, msgpack_pack_bin(pk, 8));
EXPECT_EQ(0, msgpack_pack_bin_body(pk, "bin_data", 8)); EXPECT_EQ(0, msgpack_pack_bin_body(pk, "bin_data", 8));
EXPECT_EQ(0, msgpack_pack_map(pk, 1)); EXPECT_EQ(0, msgpack_pack_map(pk, 1));
EXPECT_EQ(0, msgpack_pack_float(pk, 0.4)); EXPECT_EQ(0, msgpack_pack_float(pk, 0.4f));
EXPECT_EQ(0, msgpack_pack_double(pk, 0.8)); EXPECT_EQ(0, msgpack_pack_double(pk, 0.8));
int max_count = 6; int max_count = 6;
@ -98,7 +98,7 @@ TEST(streaming, basic)
EXPECT_EQ(1, obj.via.map.size); EXPECT_EQ(1, obj.via.map.size);
e = obj.via.map.ptr[0].key; e = obj.via.map.ptr[0].key;
EXPECT_EQ(MSGPACK_OBJECT_DOUBLE, e.type); EXPECT_EQ(MSGPACK_OBJECT_DOUBLE, e.type);
ASSERT_FLOAT_EQ(0.4, (float)e.via.dec); ASSERT_FLOAT_EQ(0.4f, (float)e.via.dec);
e = obj.via.map.ptr[0].val; e = obj.via.map.ptr[0].val;
EXPECT_EQ(MSGPACK_OBJECT_DOUBLE, e.type); EXPECT_EQ(MSGPACK_OBJECT_DOUBLE, e.type);
ASSERT_DOUBLE_EQ(0.8, e.via.dec); ASSERT_DOUBLE_EQ(0.8, e.via.dec);

View File

@ -20,7 +20,7 @@ TEST(zone, allocate_align_custom)
char* start = (char*)z.allocate_align(1, align); char* start = (char*)z.allocate_align(1, align);
EXPECT_EQ(reinterpret_cast<std::size_t>(start) % align, 0); EXPECT_EQ(reinterpret_cast<std::size_t>(start) % align, 0);
for (std::size_t s = 1; s < align; ++s) { for (std::size_t s = 1; s < align; ++s) {
(char*)z.allocate_no_align(s); z.allocate_no_align(s);
char* buf_a = (char*)z.allocate_align(1, align); char* buf_a = (char*)z.allocate_align(1, align);
EXPECT_EQ(0, reinterpret_cast<std::size_t>(buf_a) % align); EXPECT_EQ(0, reinterpret_cast<std::size_t>(buf_a) % align);
} }