Bug#265448: 3dwm: FTBFS with gcc-3.4: `Math::tolerance' cannot appear in a constant-expression
Package: 3dwm
Severity: normal
Tags: patch
When building '3dwm' with gcc-3.4 I get the following error:
c++ -DHAVE_CONFIG_H -I. -I. -I../../include -I../../include/Celsius -Wall -Wp,-MD,.deps/Matrix3D.pp -c Matrix3D.cc -fPIC -DPIC -o .libs/Matrix3D.lo
In file included from ../../include/Celsius/Matrix3D.hh:41,
from Matrix3D.cc:36:
../../include/Celsius/Math.hh:50: error: `Math::tolerance' cannot appear in a constant-expression
../../include/Celsius/Math.hh:56: error: `Math::pi' cannot appear in a constant-expression
../../include/Celsius/Math.hh:57: error: `Math::pi' cannot appear in a constant-expression
make[4]: *** [Matrix3D.lo] Error 1
make[4]: Leaving directory `/3dwm-0.3.1/src/Celsius'
With the attached patch '3dwm' can be compiled using gcc-3.4.
Regards
Andreas Jochens
diff -urN ../tmp-orig/3dwm-0.3.1/include/Celsius/Math.hh ./include/Celsius/Math.hh
--- ../tmp-orig/3dwm-0.3.1/include/Celsius/Math.hh 2001-08-16 13:32:20.000000000 +0200
+++ ./include/Celsius/Math.hh 2004-08-13 09:22:59.803827561 +0200
@@ -47,14 +47,14 @@
/// Machine precision (@@@ Put some research into this!)
const static double tolerance = 1e-5;
- const static double epsilon = tolerance;
+ const static double epsilon = 1e-5;
// Value of pi
const static double pi = M_PI;
// Degree <-> radian conversion
- const static double radians_per_degree = pi / 180.;
- const static double degrees_per_radian = 180. / pi;
+ const static double radians_per_degree = M_PI / 180.;
+ const static double degrees_per_radian = 180. / M_PI;
static double degToRad(double deg) { return deg * radians_per_degree; }
static double radToDeg(double rad) { return rad * degrees_per_radian; }
diff -urN ../tmp-orig/3dwm-0.3.1/include/Polhem/SolidCache.hh ./include/Polhem/SolidCache.hh
--- ../tmp-orig/3dwm-0.3.1/include/Polhem/SolidCache.hh 2004-08-13 10:16:58.844418545 +0200
+++ ./include/Polhem/SolidCache.hh 2004-08-13 09:22:59.804827409 +0200
@@ -72,7 +72,7 @@
/**
* Cache key hash function object.
**/
- struct hash<cache_key_t> {
+ template <> struct hash<cache_key_t> {
/// Arbitrary number of partitions for IORs
static const unsigned int hash_max = 64;
diff -urN ../tmp-orig/3dwm-0.3.1/reconfig ./reconfig
--- ../tmp-orig/3dwm-0.3.1/reconfig 2004-08-13 10:16:58.901409881 +0200
+++ ./reconfig 2004-08-13 09:23:30.862105985 +0200
@@ -1,2 +1,2 @@
rm -f config.status config.cache config.log
-./configure --prefix= --exec-prefix=${prefix}/usr --datadir=${exec-prefix}/share --includedir=${exec-prefix}/include --mandir=${exec-prefix}/share/man --infodir=${exec-prefix}/share/info
+./configure --prefix= '--exec-prefix=${prefix}/usr' '--datadir=${exec-prefix}/share' '--includedir=${exec-prefix}/include' '--mandir=${exec-prefix}/share/man' '--infodir=${exec-prefix}/share/info'
diff -urN ../tmp-orig/3dwm-0.3.1/src/Polhem/Platform.cc ./src/Polhem/Platform.cc
--- ../tmp-orig/3dwm-0.3.1/src/Polhem/Platform.cc 2001-06-20 14:32:13.000000000 +0200
+++ ./src/Polhem/Platform.cc 2004-08-13 10:16:45.136502465 +0200
@@ -46,7 +46,7 @@
#elif defined(PLATFORM_SDL)
# include "SDLPlatform.cc"
-SDLPlatform *Platform::t = 0;
+template <> SDLPlatform *Platform::t = 0;
#elif defined(PLATFORM_SDL_FBCON)
# include "SDLfbconPlatform.cc"
@@ -63,4 +63,4 @@
#endif
// Reaper struct (takes care of deallocating the implementation when done)
-Platform::Reaper Platform::reaper;
+template <> Platform::Reaper Platform::reaper;
Reply to: