Errors building with Qt5.5

• Jul 7, 2015 - 18:32

Compiling the current trunk (a1dc572) using the new Qt5.5 fails on Kubuntu 14.04 using gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04):

In file included from /home/joern/Qt55/5.5/gcc_64/include/QtCore/qnamespace.h:37:0,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtCore/qobjectdefs.h:41,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtCore/qobject.h:40,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtCore/qabstractanimation.h:37,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtCore/QtCore:4,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtGui/QtGuiDepends:3,
                 from /home/joern/Qt55/5.5/gcc_64/include/QtGui/QtGui:3,
                 from all.h:32:
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp: In function ‘void Ms::quantizeAllTracks(std::multimap&, Ms::TimeSigMap*, const Ms::ReducedFraction&)’:
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:232:24: error: ‘isLastTickValid’ is not a member of ‘Ms::MChord’
             Q_ASSERT_X(MChord::isLastTickValid(lastTick, mtrack.chords),
                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:242:52: error: ‘doNotesOverlap’ was not declared in this scope
             Q_ASSERT_X(!doNotesOverlap(track.second),
                                                    ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:252:24: error: ‘areTupletRangesOk’ is not a member of ‘Ms::MidiTuplet’
             Q_ASSERT_X(MidiTuplet::areTupletRangesOk(mtrack.chords, mtrack.tuplets),
                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
Building CXX object mscore/CMakeFiles/mscore.dir/importmidi/importmidi_model.cpp.o                                                                              
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp: In function ‘void Ms::applySwing(QList&)’:
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:1000:24: error: ‘areTiesConsistent’ is not a member of ‘Ms::MidiTie’
             Q_ASSERT_X(MidiTie::areTiesConsistent(mt.staff),
                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:1003:24: error: ‘haveTupletsEnoughElements’ is not a member of ‘Ms::MidiTuplet’
             Q_ASSERT_X(MidiTuplet::haveTupletsEnoughElements(mt.staff),
                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp: In function ‘void Ms::convertMidi(Ms::Score*, const Ms::MidiFile*)’:
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:1115:40: error: ‘doNotesOverlap’ was not declared in this scope
       Q_ASSERT_X(!doNotesOverlap(tracks),
                                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
/home/joern/MuseScoreQt55/mscore/importmidi/importmidi.cpp:1127:40: error: ‘noTooShortNotes’ was not declared in this scope
       Q_ASSERT_X(noTooShortNotes(tracks),
                                        ^
/home/joern/Qt55/5.5/gcc_64/include/QtCore/qglobal.h:684:69: note: in definition of macro ‘Q_ASSERT_X’
 #    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
                                                                     ^
make[3]: *** [mscore/CMakeFiles/mscore.dir/importmidi/importmidi.cpp.o] Fehler 1
make[3]: *** Auf noch nicht beendete Prozesse wird gewartet …
make[3]: Verzeichnis »/home/joern/MuseScoreQt55/build.release« wird verlassen
make[2]: *** [mscore/CMakeFiles/mscore.dir/all] Fehler 2
make[2]: Verzeichnis »/home/joern/MuseScoreQt55/build.release« wird verlassen
make[1]: *** [all] Fehler 2
make[1]: Verzeichnis »/home/joern/MuseScoreQt55/build.release« wird verlassen
make: *** [release] Fehler 2

Comments

I think this is due to the new definition of Q_ASSERT_X in Qt5.5:
In Qt5.4:

#if !defined(Q_ASSERT_X)
#  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
#    define Q_ASSERT_X(cond, where, what) qt_noop()
#  else
[...]

In Qt5.5:

#if !defined(Q_ASSERT_X)
#  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
#    define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
#  else
[..]

So, while in Qt5.4 cond was not used if QT_NO_DEBUG was set, it will always be seen by the compiler in Qt5.5 (whether QT_DEBUG is set or not), which means it needs to be defined even if QT_DEBUG is not set, which currently is not done by the code of importmidi.

See https://github.com/musescore/MuseScore/pull/2109 for one possible solution.

In reply to by [DELETED] 5

I still don't understand the reason of this change in Qt. In previous Qt versions there was no need to #ifndef functions for assertions only as well. #ifndef (or #ifdef QT_DEBUG) around such functions was just a small optimization to not include unused code into release build. Q_ASSERT argument validity check does not seem to be very reasonable.

Do you still have an unanswered question? Please log in first to post your question.