mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-23 00:08:01 +02:00
cpp: fixes some implicit cast warnings
This commit is contained in:
@@ -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)
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user