From f07bf28f5f4a3008eefecaf5a2b6e7becbfce0bb Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 8 May 2013 00:27:36 +0900 Subject: [PATCH] Fixed GCC warnings about incompatible type conversions --- taglib/ebml/ebmlelement.cpp | 1 + taglib/toolkit/tbytevector.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/taglib/ebml/ebmlelement.cpp b/taglib/ebml/ebmlelement.cpp index 1419aa92..32ce46de 100644 --- a/taglib/ebml/ebmlelement.cpp +++ b/taglib/ebml/ebmlelement.cpp @@ -23,6 +23,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ +#include "tdebug.h" #include "ebmlelement.h" using namespace TagLib; diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index c58dbb3d..19e2c8f4 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -849,14 +849,17 @@ float ByteVector::toFloat32BE(size_t offset) const { // float is 32-bit wide and IEEE754 compliant. - uint tmp; + union { + uint i; + float f; + } tmp; ::memcpy(&tmp, data() + offset, 4); # if SYSTEM_BYTEORDER == 1 - tmp = byteSwap(tmp); + tmp.i = byteSwap(tmp.i); # endif - return *reinterpret_cast(&tmp); + return tmp.f; } #endif @@ -907,14 +910,17 @@ double ByteVector::toFloat64BE(size_t offset) const { // double is 64-bit wide and IEEE754 compliant. - ulonglong tmp; + union { + ulonglong i; + double f; + } tmp; ::memcpy(&tmp, data() + offset, 8); # if SYSTEM_BYTEORDER == 1 - tmp = byteSwap(tmp); + tmp.i = byteSwap(tmp.i); # endif - return *reinterpret_cast(&tmp); + return tmp.f; } #endif