|
24 | 24 | // SOFTWARE.
|
25 | 25 | ////////////////////////////////////////////////////////////////////////////////
|
26 | 26 |
|
27 |
| -// NVIDIA CodeWorks used for Android has an old version of Clang that does not fully support C++11 |
28 |
| -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 |
29 |
| - #include <stdlib.h> |
30 |
| -#else |
| 27 | +#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) |
31 | 28 | #include <cstdlib>
|
| 29 | +#else |
| 30 | + #include <stdlib.h> |
32 | 31 | #endif
|
33 | 32 |
|
34 | 33 | namespace sjson
|
35 | 34 | {
|
36 |
| - namespace impl |
| 35 | + ////////////////////////////////////////////////////////////////////////// |
| 36 | + // The version of the STL shipped with versions of GCC older than 5.1 are missing a number of type traits and functions, |
| 37 | + // such as std::is_trivially_default_constructible. |
| 38 | + // In this case, we polyfill the proper standard names using the deprecated std::has_trivial_default_constructor. |
| 39 | + // This must also be done when the compiler is clang when it makes use of the GCC implementation of the STL, |
| 40 | + // which is the default behavior on linux. Properly detecting the version of the GCC STL used by clang cannot |
| 41 | + // be done with the __GNUC__ macro, which are overridden by clang. Instead, we check for the definition |
| 42 | + // of the macro ``_GLIBCXX_USE_CXX11_ABI`` which is only defined with GCC versions greater than 5. |
| 43 | + ////////////////////////////////////////////////////////////////////////// |
| 44 | + namespace sjson_impl |
37 | 45 | {
|
38 |
| - inline unsigned long long int strtoull(const char* str, char** endptr, int base) |
39 |
| - { |
40 |
| -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 |
41 |
| - return ::strtoull(str, endptr, base); |
42 |
| -#else |
43 |
| - return std::strtoull(str, endptr, base); |
44 |
| -#endif |
45 |
| - } |
46 |
| - |
47 |
| - inline long long int strtoll(const char* str, char** endptr, int base) |
48 |
| - { |
49 |
| -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 |
50 |
| - return ::strtoll(str, endptr, base); |
51 |
| -#else |
52 |
| - return std::strtoll(str, endptr, base); |
53 |
| -#endif |
54 |
| - } |
55 |
| - |
56 |
| - inline float strtof(const char* str, char** endptr) |
57 |
| - { |
58 |
| -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 |
59 |
| - return ::strtof(str, endptr); |
| 46 | +#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) |
| 47 | + using std::strtoull; |
| 48 | + using std::strtoll; |
| 49 | + using std::strtof; |
60 | 50 | #else
|
61 |
| - return std::strtof(str, endptr); |
| 51 | + using ::strtoull; |
| 52 | + using ::strtoll; |
| 53 | + using ::strtof; |
62 | 54 | #endif
|
63 |
| - } |
64 | 55 | }
|
65 | 56 | }
|
0 commit comments