diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 7a9c6746..e7b18918 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -282,47 +282,47 @@ ByteVector ByteVector::fromCString(const char *s, unsigned int length) ByteVector ByteVector::fromUInt(unsigned int value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromUShort(unsigned short value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromULongLong(unsigned long long value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromFloat32LE(float value) { - return fromFloat(value); + return fromFloat(value); } ByteVector ByteVector::fromFloat32BE(float value) { - return fromFloat(value); + return fromFloat(value); } ByteVector ByteVector::fromFloat64LE(double value) { - return fromFloat(value); + return fromFloat(value); } ByteVector ByteVector::fromFloat64BE(double value) { - return fromFloat(value); + return fromFloat(value); } //////////////////////////////////////////////////////////////////////////////// @@ -656,79 +656,86 @@ bool ByteVector::isEmpty() const return d->length == 0; } +// Sanity checks +static_assert(sizeof(unsigned short) == sizeof(uint16_t), "unsigned short and uint16_t are different sizes"); +static_assert(sizeof(unsigned int) == sizeof(uint32_t), "unsigned int and uint32_t are different sizes"); +static_assert(sizeof(unsigned long long) == sizeof(uint64_t), "unsigned long long and uint64_t are different sizes"); +static_assert(sizeof(float) == sizeof(uint32_t), "float and uint32_t are different sizes"); +static_assert(sizeof(double) == sizeof(uint64_t), "double and uint64_t are different sizes"); + unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } unsigned int ByteVector::toUInt(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } unsigned int ByteVector::toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, length, mostSignificantByteFirst); + return toNumber(*this, offset, length, mostSignificantByteFirst); } short ByteVector::toShort(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } short ByteVector::toShort(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } unsigned short ByteVector::toUShort(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } unsigned short ByteVector::toUShort(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } long long ByteVector::toLongLong(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } long long ByteVector::toLongLong(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } unsigned long long ByteVector::toULongLong(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } unsigned long long ByteVector::toULongLong(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } float ByteVector::toFloat32LE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } float ByteVector::toFloat32BE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } double ByteVector::toFloat64LE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } double ByteVector::toFloat64BE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } long double ByteVector::toFloat80LE(size_t offset) const diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index a17e5566..d18aa2ee 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -30,6 +30,7 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header +#include #include #include #include @@ -60,7 +61,7 @@ namespace TagLib /*! * Reverses the order of bytes in a 16-bit integer. */ - inline unsigned short byteSwap(unsigned short x) + inline uint16_t byteSwap(uint16_t x) { #if defined(HAVE_GCC_BYTESWAP) @@ -92,7 +93,7 @@ namespace TagLib /*! * Reverses the order of bytes in a 32-bit integer. */ - inline unsigned int byteSwap(unsigned int x) + inline uint32_t byteSwap(uint32_t x) { #if defined(HAVE_GCC_BYTESWAP) @@ -127,7 +128,7 @@ namespace TagLib /*! * Reverses the order of bytes in a 64-bit integer. */ - inline unsigned long long byteSwap(unsigned long long x) + inline uint64_t byteSwap(uint64_t x) { #if defined(HAVE_GCC_BYTESWAP)