summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2018-02-22 08:11:02 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2018-02-22 08:15:53 -0800
commit2ec3579f296fdea783a806179424b28b2f3c0100 (patch)
tree7c95de848e0926aa2dad3bc1d49bebe766b25b12 /src/pugixml.cpp
parent9bb468b3a960421b2ae3a3f232fbda477f42d2f4 (diff)
Work around gcc issues with limits.h not defining LLONG_MIN
It looks like there are several cases where this might happen: - In some MinGW distributions, the LLONG_MIN/etc defines are guarded with: #if !defined(__STRICT_ANSI__) && defined(__GNUC__) Which means that you don't get them in strict ANSI mode. The previous workaround was specifically targeted towards this. - In some GCC distributions (notably GCC 6.3.0 in some configurations), LLONG_MIN/etc. defines are guarded with: #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) But __STDC_VERSION__ isn't defined as C99 even if you use -std=c++14 - which is probably technically valid, but not useful. To work around this, redefine the symbols whenever we are building with GCC and we need them and they aren't defined - doing this is better than not building. Instead of hard-coding the constants, use GCC-specific __LONG_LONG_MAX__ to compute them. Fixes #181.
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 82e46dc..b06eacb 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -120,11 +120,11 @@ using std::memmove;
using std::memset;
#endif
-// Some MinGW versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions in strict ANSI mode
-#if defined(PUGIXML_HAS_LONG_LONG) && defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX)
-# define LLONG_MAX 9223372036854775807LL
-# define LLONG_MIN (-LLONG_MAX-1)
-# define ULLONG_MAX (2ULL*LLONG_MAX+1)
+// Some MinGW/GCC versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions from limits.h in some configurations
+#if defined(PUGIXML_HAS_LONG_LONG) && defined(__GNUC__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX)
+# define LLONG_MIN (-LLONG_MAX - 1LL)
+# define LLONG_MAX __LONG_LONG_MAX__
+# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
#endif
// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features