From 67ab510b5de7cb21feaa12667cabe1a16a2b9194 Mon Sep 17 00:00:00 2001 From: FURUHASHI Sadayuki <frsyuki@users.sourceforge.jp> Date: Wed, 23 Feb 2011 23:48:26 +0900 Subject: [PATCH] cpp: fixes some implicit cast warnings --- cpp/configure.in | 2 +- cpp/src/msgpack/type/float.hpp | 4 ++-- cpp/src/msgpack/type/int.hpp | 6 +++--- cpp/src/objectc.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp/configure.in b/cpp/configure.in index 2dd92d18..23d7d6ee 100644 --- a/cpp/configure.in +++ b/cpp/configure.in @@ -55,7 +55,7 @@ if test "$msgpack_cv_atomic_ops" != "yes"; then Note that gcc < 4.1 is not supported. If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to -add CFLAGS="--march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows: +add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows: $ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686" ]) diff --git a/cpp/src/msgpack/type/float.hpp b/cpp/src/msgpack/type/float.hpp index a60ef0bf..11df6b2c 100644 --- a/cpp/src/msgpack/type/float.hpp +++ b/cpp/src/msgpack/type/float.hpp @@ -30,7 +30,7 @@ namespace msgpack { inline float& operator>> (object o, float& v) { if(o.type != type::DOUBLE) { throw type_error(); } - v = o.via.dec; + v = (float)o.via.dec; return v; } @@ -60,7 +60,7 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const double& v) inline void operator<< (object& o, float v) { o.type = type::DOUBLE; - o.via.dec = v; + o.via.dec = (double)v; } inline void operator<< (object& o, double v) diff --git a/cpp/src/msgpack/type/int.hpp b/cpp/src/msgpack/type/int.hpp index e2d18209..e45121df 100644 --- a/cpp/src/msgpack/type/int.hpp +++ b/cpp/src/msgpack/type/int.hpp @@ -35,11 +35,11 @@ namespace detail { if(o.type == type::POSITIVE_INTEGER) { if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max()) { throw type_error(); } - return o.via.u64; + return (T)o.via.u64; } else if(o.type == type::NEGATIVE_INTEGER) { if(o.via.i64 < (int64_t)std::numeric_limits<T>::min()) { throw type_error(); } - return o.via.i64; + return (T)o.via.i64; } throw type_error(); } @@ -51,7 +51,7 @@ namespace detail { if(o.type == type::POSITIVE_INTEGER) { if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max()) { throw type_error(); } - return o.via.u64; + return (T)o.via.u64; } throw type_error(); } diff --git a/cpp/src/objectc.c b/cpp/src/objectc.c index d4f1c8aa..548e923e 100644 --- a/cpp/src/objectc.c +++ b/cpp/src/objectc.c @@ -164,7 +164,7 @@ void msgpack_object_print(FILE* out, msgpack_object o) default: // FIXME - fprintf(out, "#<UNKNOWN %hu %"PRIu64">", o.type, o.via.u64); + fprintf(out, "#<UNKNOWN %i %"PRIu64">", o.type, o.via.u64); } }