From 5e2b2704015a05784f37ac0bbe69d68677d2ed49 Mon Sep 17 00:00:00 2001 From: Paul Colby Date: Fri, 19 Aug 2016 21:00:49 +1000 Subject: [PATCH] Allow for parameter type changes in Qt 5.7 (#69) In Qt 5.7, a number of endian-swapping function parameters were changed from uchar to void pointers. See qtbase commit [5c2ff22]( https://github.com/qt/qtbase/commit/5c2ff22ba117f295718c529198ab42ee4646d90c). --- src/protobuf/fixnum.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/protobuf/fixnum.cpp b/src/protobuf/fixnum.cpp index be548bfe..73b310d9 100644 --- a/src/protobuf/fixnum.cpp +++ b/src/protobuf/fixnum.cpp @@ -32,18 +32,28 @@ template inline Dst copyAligned(const Src src) return dst; } +// In Qt 5.7, these the endian-swapping functions were changed to use void +// instead of uchar. See Qt commit 5c2ff22ba117f295718c529198ab42ee4646d90c. +#if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) +#define ENDIAN_SWAPPING_PARAM_TYPE const uchar * +#else +#define ENDIAN_SWAPPING_PARAM_TYPE const void * +#endif + // Template specialisation for double (not included in Qt). -template<> double qFromLittleEndian(const uchar * src) +template<> double qFromLittleEndian(ENDIAN_SWAPPING_PARAM_TYPE src) { return copyAligned(qFromLittleEndian(src)); } // Template specialisation for float (not included in Qt). -template<> float qFromLittleEndian(const uchar * src) +template<> float qFromLittleEndian(ENDIAN_SWAPPING_PARAM_TYPE src) { return copyAligned(qFromLittleEndian(src)); } +#undef ENDIAN_SWAPPING_PARAM_TYPE + namespace ProtoBuf { /// @tparam Type May be one of: qint32, quint32, qint64, quint64, float or double.