Skip to content

Commit

Permalink
src/MPDeviceBleImpl.cpp: Fix compilation on GCC 14
Browse files Browse the repository at this point in the history
GCC begins to get stricter regarding types in 14, meaning it will no
longer allow casting a type `int` to `const char*`. This was fixed by simply
casting the 0 to a `char*` with `QByteArray::number(0)`.

Gentoo bug: https://bugs.gentoo.org/916994

Error output:

src/MPDeviceBleImpl.cpp: In member function ‘QVector<QByteArray> MPDeviceBleImpl::processReceivedStartNodes(const QByteArray&) const’:
src/MPDeviceBleImpl.cpp:738:18: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
  738 |         return {0};
      |                  ^
      |                  |
      |                  int
In file included from /usr/include/qt5/QtCore/qstring.h:50,
                 from /usr/include/qt5/QtCore/qobject.h:47,
                 from /usr/include/qt5/QtCore/QObject:1,
                 from src/MPDevice.h:22,
                 from src/MPDeviceBleImpl.h:4,
                 from src/MPDeviceBleImpl.cpp:1:
/usr/include/qt5/QtCore/qbytearray.h:181:16: note:   initializing argument 1 of ‘QByteArray::QByteArray(const char*, int)’
  181 |     QByteArray(const char *, int size = -1);
      |                ^~~~~~~~~~~~
  • Loading branch information
csfore committed Dec 10, 2023
1 parent 1aa045a commit 9698273
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/MPDeviceBleImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ bool MPDeviceBleImpl::processReceivedData(const QByteArray &data, QByteArray &da
{
if (data.size() < 2)
{
return {0};
return {QByteArray::number(0)};
}
QVector<QByteArray> res;
for (int i = 0; i < data.size() - 1; i += 2)
Expand Down

0 comments on commit 9698273

Please sign in to comment.