rng2cpp.cpp build fail with qt5.5

Friedrich W. H. Kossebau kossebau at kde.org
Thu May 28 21:44:04 BST 2015


Am Donnerstag, 28. Mai 2015, 21:17:02 schrieb Treeve Jelbert:
> On Thu, 28 May 2015 21:00:17 +0200 (CEST), Boudewijn Rempt wrote:
> > On Thu, 28 May 2015, Friedrich W. H. Kossebau wrote:
> >> Hi Treeve,
> >> 
> >> thanks for reporting the error and working on a patch :)
> >> 
> >> Am Donnerstag, 28. Mai 2015, 13:31:29 schrieb Treeve Jelbert:
> >>> thanks, the following diff fixes it
> >>> diff --git a/devtools/rng2cpp/rng2cpp.cpp
> >>> b/devtools/rng2cpp/rng2cpp.cpp
> >>> index 3dc3214..de65ac4 100644
> >>> --- a/devtools/rng2cpp/rng2cpp.cpp
> >>> +++ b/devtools/rng2cpp/rng2cpp.cpp
> >>> @@ -23,12 +23,10 @@
> >>> 
> >>>   #include <QtGlobal>
> >>>   #include <QSharedPointer>
> >>>   #include <QStringList>
> >>> 
> >>> +#include <QSet>
> >>> +#include <QVector>
> >> 
> >> Aha, this is why there was an offset of +2 in the build log you
> >> posted :)
> >> But, why did you add those two lines? Are they left overs from some
> >> experiment, or do you think they are needed to fix this build problem
> >> you reported?
> > 
> > I think the extra includes might be what does the trick: the Qt
> > people removed some transitive #includes in the latest Qt5, blithely
> > disregarding that that'd break code all over the world.
> 
> the includes were my first attempt.
> that reduced the number of erros, but the compile still failed.

I see, so with Qt 5.5.0, as Boud assumed, it seems more includes need to be 
explicitely done.

Your "the following diff fixes it" seemed to refer by the "it" to the breakage 
on the lines with "assert", so I was confused how that would work for that :) 

Now for the breakage with assert itself:

> >>> -#if QT_VERSION < 0x040800
> >>> -#   define assert(cond, what) (Q_ASSERT_X(cond, "",
> >>> qPrintable(QString(what))))
> >>> -#else
> >>> -#   define assert(cond, what) (Q_ASSERT_X(cond, "",
> >>> qPrintable(what)))
> >>> -#endif
> >>> +#   define assert(cond, what) Q_ASSERT_X(cond, "",
> >>> qPrintable(what))
> >>> 
> >>>   static const QString ns = "writeodf";
> >> 
> >> Can you explain why this fixes it? Is it because QT_VERSION no
> >> longer works with Qt 5.5.0, or is it the removed outer () in the
> >> replacement the culprit? Why exactly did it fail before? Can you tell
> >> how all the macros are resolved in the end with Qt 5.5.0
> 
> there was no point in testing for qt-4 versions in frameworks code.

Right. One thing though, which you might not be aware of, is that currently we 
try to keep the code in "frameworks" as close as possible to the qt4 one, 
unless really needed. It helps porting all the bugs/features forward to the 
frameworks branch, because currently most people are still focussed on the qt4 
version (calligra/2.9 branch). Will change in a few weeks surely :) 

> The important change was removing a pair of brackets.

And the reason is that in Qt 5.5.0 Q_ASSERT_X is defined by

#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
#    define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, 
what,__FILE__,__LINE__) : qt_noop())
#  endif
#endif

while before it was

#if !defined(Q_ASSERT_X)
#  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
#    define Q_ASSERT_X(cond, where, what) qt_noop()
#  else
#    define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, 
what,__FILE__,__LINE__) : qt_noop())
#  endif
#endif

And for your build it seems to hit the "defined(QT_NO_DEBUG) && 
!defined(QT_FORCE_ASSERTS)" case, given the
"error: expected primary-expression before 'do'".

I have no idea why those extra brackets have been done with 

#define assert(cond, what) (Q_ASSERT_X(cond, "", qPrintable(what)))

Removing them seems fine to me in general, for Qt 5.5.0 and before.

> Without that change, this morning's code failed. It now builds.

Okay. Now that I understand completely why it is needed, no objections from my 
side (in version which keeps the #if QT_VERSION < 0x040800 branches):
  #include <QtGlobal>
  #include <QSharedPointer>
  #include <QStringList>
+#include <QSet>
+#include <QVector>

  #if QT_VERSION < 0x040800
  #   define assert(cond, what) (Q_ASSERT_X(cond, "", 
qPrintable(QString(what))))
  #else
-#   define assert(cond, what) (Q_ASSERT_X(cond, "", qPrintable(what)))
+#   define assert(cond, what) Q_ASSERT_X(cond, "", qPrintable(what))
 #endif

Treeve, do you have push rights for the Calligra repo, or shall I commit for 
you?

Cheers
Friedrich



More information about the calligra-devel mailing list