compile failure with newer gcc
Brought to you by:
set
Hello, I'm trying to keep turbo vision for gentoo up-to-date. When I try to compile the current release rhtvision-2.2.1-4.tar.gz with gcc-7.3.0, I get this error:
g++ -I../include -I/usr/X11R6/include -fPIC -O2 -pipe -march=bdver2 -mprefer-avx128 -mvzeroupper --std=c++98 -c ../classes/tdesktop.cc -o obj/tdesktop.lo ../classes/tdesktop.cc: In function ‘unsigned int iSqr(unsigned int)’: ../classes/tdesktop.cc:151:29: error: call of overloaded ‘abs(unsigned int)’ is ambiguous while( abs( res1 - res2 ) > 1 ) ^ In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/cstdlib:75:0, from ../classes/tdesktop.cc:16: /usr/include/stdlib.h:722:12: note: candidate: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^~~ In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/cstdlib:77:0, from ../classes/tdesktop.cc:16: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/bits/std_abs.h:56:3: note: candidate: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } ^~~ /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/bits/std_abs.h:61:3: note: candidate: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^~~ /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/bits/std_abs.h:70:3: note: candidate: double std::abs(double) abs(double __x) ^~~ /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/bits/std_abs.h:74:3: note: candidate: float std::abs(float) abs(float __x) ^~~ /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/bits/std_abs.h:78:3: note: candidate: long double std::abs(long double) abs(long double __x) ^~~ make[1]: *** [librhtv.umk:1159: obj/tdesktop.lo] Error 1 make[1]: Leaving directory '/var/tmp/portage/dev-libs/tvision-2.2.1.4/work/tvision/makes' make: *** [Makefile:28: dynamic-lib] Error 2
With gcc-6 it was possible to add a
using std::abs;
to the files where this error shows up. But with gcc-7 it is no longer possible to use abs with unsigned values.
As a workaround, I changed all the variables where this error pops up to int, which let's the compilation finish, but can't tell the impact this will have on apps using the library.
See the following patch of where I had to add changes:
Is this project still alive?
I've just found the problem of 'abs'; I suggest using the following macro:
#define abs_diff(i,j) ((i)>=(j)?(i)-(j):(j)-(i))
Should interest arise, I could send patch(es).
Your macro looks cleaner then my changes to the datatype.
If you like, you can create a PR against my fork of the project at https://sourceforge.net/u/waebbl/tvision/ci/master/tree/
Well, the version I downloaded from git does compile without this problem ( git clone https://git.code.sf.net/p/tvision/code tvision-code )
Thanks for the info, but this doesn't help me. I need to prepare a versioned build for gentoo, not a live build file. If you don't want to share your patches, I guess, I need to figure them out myself, or just use my patch.
Hi, I suggest you create a patch from git version based on version 2.2.1 (from files/UNIX/2.2.1 CVS20161117/rhtvision_2.2.1-4.tar.gz) -- I'am attaching sample patch.
I think the following solves the problem, please confirm.
Bernd Waibel: do you need a tarball?
Salvador Eduardo Tropea: Sorry for the delay. The patch works partly, I needed to add the equal abs definiton to classes/tdisplay.cc too, see the attached file.
I don't need a tarball for this.
Actually a tar ball would be nice, as you have released a new release for this, which I noticed just today, but only with rpm release targets.
I moved the repor to GitHub. SF Git browser has too many bugs and I have other projects at GitHub.
https://github.com/set-soft/tvision
Last release is 2.2.3 and compiles with gcc 10.2
Thanks for the move to github, this will help me a lot.