Opened 8 years ago
Closed 8 years ago
Last modified 8 years ago
#12764 closed Patch - Bug Fix (fixed)
Bug fix - compilation of abs function with latest gcc/libstdc++
Reported by: | Owned by: | Stuart Auchterlonie | |
---|---|---|---|
Priority: | minor | Milestone: | 0.28.1 |
Component: | MythTV - Video Library | Version: | Master Head |
Severity: | medium | Keywords: | |
Cc: | Ticket locked: | no |
Description
With recent gcc and libstdc++ compilation fails with:
visualisations/videovisualcircles.cpp: In member function ‘virtual void VideoVisualCircles::DrawPriv(MythPainter*, QPaintDevice*)’: visualisations/videovisualcircles.cpp:26:75: error: call of overloaded ‘abs(double)’ is ambiguous double mag = abs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0); ^ In file included from /usr/include/c++/6.0.0/cstdlib:75:0, from /usr/include/c++/6.0.0/bits/stl_algo.h:59, from /usr/include/c++/6.0.0/algorithm:62, from /usr/include/qt5/QtCore/qglobal.h:85, from /usr/include/qt5/QtGui/qrgb.h:37, from /usr/include/qt5/QtGui/qcolor.h:37, from /usr/include/qt5/QtGui/qpen.h:37, from /usr/include/qt5/QtGui/QPen:1, from visualisations/videovisualcircles.cpp:1: /usr/include/stdlib.h:774:12: note: candidate: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^~~ In file included from /usr/include/c++/6.0.0/bits/stl_algo.h:59:0, from /usr/include/c++/6.0.0/algorithm:62, from /usr/include/qt5/QtCore/qglobal.h:85, from /usr/include/qt5/QtGui/qrgb.h:37, from /usr/include/qt5/QtGui/qcolor.h:37, from /usr/include/qt5/QtGui/qpen.h:37, from /usr/include/qt5/QtGui/QPen:1, from visualisations/videovisualcircles.cpp:1: /usr/include/c++/6.0.0/cstdlib:185:3: note: candidate: __int128 std::abs(__int128) abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } ^~~ /usr/include/c++/6.0.0/cstdlib:180:3: note: candidate: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^~~ /usr/include/c++/6.0.0/cstdlib:172:3: note: candidate: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } ^~~
The following patch fixes the issue (lightly tested) by specifying the Qt function qAbs:
diff --git a/mythtv/libs/libmythtv/visualisations/videovisualcircles.cpp b/mythtv/libs/libmythtv/visualisations/videovisualcircles.cpp index 1140372..e9cbf8f 100644 --- a/mythtv/libs/libmythtv/visualisations/videovisualcircles.cpp +++ b/mythtv/libs/libmythtv/visualisations/videovisualcircles.cpp @@ -23,7 +23,7 @@ void VideoVisualCircles::DrawPriv(MythPainter *painter, QPaintDevice* device) painter->Begin(device); for (int i = 0; i < count; i++, rad += m_range, red += incr, green -= incr) { - double mag = abs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0); + double mag = qAbs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0); if (mag > 1.0) { pen.setWidth((int)mag);
Change History (6)
comment:1 follow-up: 2 Changed 8 years ago by
Milestone: | unknown → 0.28.1 |
---|---|
Owner: | changed from JYA to Stuart Auchterlonie |
Status: | new → assigned |
comment:2 Changed 8 years ago by
Replying to stuarta:
Does this also work if you do the change as follows??
'std::abs', not '::abs', works (well, it compiles, I have no idea about the visualization results).
I was under the impression (based on the wording in the "coding standards" wiki entry) that using Qt abstraction was usually preferred, which is why I suggested the Qt variant in this case.
comment:4 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
Does this also work if you do the change as follows??
This forces use of the stdlib abs function