On Mon, Jun 18, 2007 at 08:03:21AM +0200, Andre Poenitz wrote: > On Mon, Jun 18, 2007 at 04:20:13AM +0200, Enrico Forestieri wrote: > > On Tue, Jun 12, 2007 at 11:28:37PM +0200, Edwin Leuven wrote: > > > > > >> +// FIXME: this can go when we move to Qt 4.3 > > > >> +#define QT_VERSION_CHECK(major, minor, patch) > > > >> ((major<<16)|(minor<<8)|(patch)) > > > >> + > > > >> +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) > > > > > > > > Wouldn't that give a 'redefine macro' ith 4.3? > > > > > > > > Why not simply using 0x40200? > > > > > > because my compiler doesn't like it? > > > > Erm... seems that the Qt4.1 moc wants 0x040200 and don't understand > > QT_VERSION_CHECK(4, 2, 0). I have to use the attached patch in order > > to avoid the following compile error: > > It looks like either moc doesn't care much about the actual condition > but decides whether to use the 'if' or the 'else' branch solely > depending on the structure of the line (macro with parameters vs macro > without).
Definitely. I think that the problem is that moc doesn't parse #include'd files, such that QT_VERSION is really undefined. Moreover, it doesn't seem to perform like the preprocessor, such that the QT_VERSION_CHECK macro is useless. Using the attached patch I was able to compile using Qt 4.2.2 and, after changing the definition for QT_VERSION to 0x040100, compilation went fine for Qt 4.1.4, too. How can this be solved? -- Enrico
Index: src/frontends/qt4/IconPalette.h =================================================================== --- src/frontends/qt4/IconPalette.h (revision 18815) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -17,10 +17,11 @@ #include <QLayout> #include "Action.h" -// FIXME: this can go when we move to Qt 4.3 -#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) +#ifndef QT_VERSION +#define QT_VERSION 0x040200 +#endif -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= 0x040200 #include <QWidgetAction> #endif @@ -30,7 +31,7 @@ namespace frontend { /** * For holding an arbitrary set of icons. */ -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= 0x040200 class IconPalette : public QWidgetAction { Q_OBJECT