[Interest] Qt5 - Application compile error on overloaded qRound()
Rohan McGovern
rohan.mcgovern at nokia.com
Fri Aug 31 04:55:06 CEST 2012
Syam Krishnan said:
> Hi
> I downloaded Qt5 and compiled it successfully on Fedora 17, x86-64, gcc
> 4.7.0.
> The I tried to build Qwt (svn version) against it and hit a compile
> error:
> -----------------------------------------------------------------------
> ---
> timescaleengine.cpp:235:57: error: call of overloaded âqRound(int)â is
> ambiguous
> timescaleengine.cpp:235:57: note: candidates are:
> In file included from timedate.h:4:0,
> from timescaleengine.h:4,
> from timescaleengine.cpp:1:
> ../../../../Downloads/qt-everywhere-opensource-src-5.0.0-beta1/qtbase/i
> nclude/QtCore/qglobal.h:416:13: note: int qRound(double)
> ../../../../Downloads/qt-everywhere-opensource-src-5.0.0-beta1/qtbase/i
> nclude/QtCore/qglobal.h:418:13: note: int qRound(float)
> -----------------------------------------------------------------------
> ---
> I checked qglobal.h and there are two overloads for qRound(), one
> taking a float and another a double. Qwt code calls qRound() with an
> int and the
> compiler is finding it ambiguous.
> I tried with a test program and gcc indeed refuses to resolve such
> overloads.
> I checked with the installed version of Qt (4.8.2) and in qglobal.h,
> there's only one version of qRound():
> Q_DECL_CONSTEXPR inline int qRound(qreal d)
> { return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) +
> qreal(0.5)) + int(d-1); }
> This version (qreal is a typedef to double) is matching with the
> documentation (even Qt5 documentation mentions only qreal).
> Should this be reported as a bug against Qt5? Another function
> qRound64() also may have a problem.
It doesn't seem like a Qt bug; rounding an integer doesn't make sense,
right? It should be checked why that code (timescaleengine.cpp:235) is
apparently attempting to round an integer.
More information about the Interest
mailing list