summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/AppHdr.h
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2013-06-26 02:09:21 -0400
committerNeil Moore <neil@s-z.org>2013-06-26 02:09:21 -0400
commitcae46e358690cf86f43a5743b5b048be0652072e (patch)
tree8177509cb344ac595eac17915a0db73110be8711 /crawl-ref/source/AppHdr.h
parentf7884f727291f35773e451c2aa1c1d7db7aa8fec (diff)
downloadcrawl-ref-cae46e358690cf86f43a5743b5b048be0652072e.tar.gz
crawl-ref-cae46e358690cf86f43a5743b5b048be0652072e.zip
Fix compilation with old (4.1) GCC and libstdc++
We use GCC version <= 4.1 as the criterion for the fix (which is the same as the similar Solaris fix). Probably we could use __GLIBCXX__ and/or __GLIBCPP__ to detect this better, but I haven't been able to test that (in particular, old g++ with a different libstdc++). This reverts commit 0e1e71dfe8e254a2d925fcb0a7ee6905c4175dd1. We still have to do some kind of casting for that particular case, though, because the first argument is unsigned.
Diffstat (limited to 'crawl-ref/source/AppHdr.h')
-rw-r--r--crawl-ref/source/AppHdr.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index 5c2b613978..d73d2a1adc 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -45,10 +45,15 @@ static inline T move(T x) { return x; } // good enough for our purposes
#define ENUM_INT64
#endif
-#ifdef __sun
-// Solaris libc has ambiguous overloads for float, double, long float, so
-// we need to upgrade ints explicitely:
-#include <math.h>
+#if defined(__sun) || defined(__GNUC__) \
+ && __GNUC__ * 100 + __GNUC_MINOR__ <= 401
+// Solaris libc and older GNU libstdc++ have ambiguous overloads for
+// float, double, long float, so we need to upgrade ints explicitely.
+# ifndef __sun
+# include <cmath>
+# else
+# include <math.h> // XXX: Does Solaris really need this and not <cmath>?
+# endif
static inline double sqrt(int x) { return sqrt((double)x); }
static inline double atan2(int x, int y) { return atan2((double)x, (double)y); }
static inline double pow(int x, int y) { return std::pow((double)x, y); }