Skip to content

Commit

Permalink
Allow for parameter type changes in Qt 5.7 (#69)
Browse files Browse the repository at this point in the history
In Qt 5.7, a number of endian-swapping function parameters were changed
from uchar to void pointers.

See qtbase commit [5c2ff22](
qt/qtbase@5c2ff22).
  • Loading branch information
pcolby committed Aug 19, 2016
1 parent e788d58 commit 5e2b270
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/protobuf/fixnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,28 @@ template<typename Src, typename Dst> 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<double>(const uchar * src)
template<> double qFromLittleEndian<double>(ENDIAN_SWAPPING_PARAM_TYPE src)
{
return copyAligned<quint64, double>(qFromLittleEndian<quint64>(src));
}

// Template specialisation for float (not included in Qt).
template<> float qFromLittleEndian<float>(const uchar * src)
template<> float qFromLittleEndian<float>(ENDIAN_SWAPPING_PARAM_TYPE src)
{
return copyAligned<quint32, float>(qFromLittleEndian<quint32>(src));
}

#undef ENDIAN_SWAPPING_PARAM_TYPE

namespace ProtoBuf {

/// @tparam Type May be one of: qint32, quint32, qint64, quint64, float or double.
Expand Down

0 comments on commit 5e2b270

Please sign in to comment.