[Development] Dropping the variadic version of QSKIP
Olivier Goffart
olivier at woboq.com
Wed Jul 10 19:43:09 CEST 2013
On Wednesday 10 July 2013 09:46:48 Thiago Macieira wrote:
> On quarta-feira, 10 de julho de 2013 15.09.41, Albert Astals Cid wrote:
> > Hi all, in 14cd2678396ed1450a72aeffa99c1504743ea415 a variadic version of
> > QSKIP was added so that the old Qt4 version of
> >
> > QSKIP(statement, mode)
> >
> > would compile on C++11 enabled compilers silently ignoring the mode.
> >
> > This has a down side, it is causing that code like
> >
> > QSKIP("HOLA");
> >
> > gives
> >
> > warning: ISO C99 requires rest arguments to be used [enabled by default]
> >
> > when compiled with -pedantic and C++11
> >
> > Furthermore, things like
> >
> > QSKIP("HOLA", SkipSingle);
> >
> > don't compile anymore because moc complains
> >
> > main.cpp:11: Error: Macro argument mismatch.
> >
> > So it doesn't seem it makes much sense to keep the variadic version of
> > QSKIP to enable the compatibility with the old Qt4 syntax if moc is not
> > accepting it anymore.
> >
> > Would you guys accept a patch that drops the variadic version of QSKIP?
>
> Well, there is a moc bug in the parsing of variadic macros, evidently.
There is no bug.
The QSKIP is defined depending on Q_COMPILER_VARIADIC_MACROS which itslef is
defined depending on a builtin gcc macro wich is not given to moc.
So moc beleive QSKIP only take one argument.
The solution would be to add a || defined (Q_MOC_RUN)
Arguably, moc could perhaps be more error tollerent in this case.
> Is there any way we can use the rest arguments without making them take
> effect? Such as by making a string out of them that doesn't get used
> anywhere:
>
> #define QSKIP(x, ...)
> { static const char _[] = #__VA_ARGS__; } \
> [existing code]
That's not the problem. GCC's warning message is not obtimal. clang is (as
usual :-p) better:
warning: must specify at least one argument for '...' parameter of variadic
macro [-Wgnu]
In other words: the problem is that one call QSKIP with only one argument
instead of at least 2.
maybe something like:
#define QSKIP(...) QSKIP2(__VA_ARGS__ , _)
--
Olivier
Woboq - Qt services and support - http://woboq.com - http://code.woboq.org
More information about the Development
mailing list