From e9d8f08561e9989aee2d6abe2b10d2f72fb2c7cf Mon Sep 17 00:00:00 2001 From: badaix Date: Tue, 13 Mar 2018 07:47:40 +0100 Subject: [PATCH] Fix compilation error on Android NDK level < 21 --- common/json.hpp | 4 ++-- common/strCompat.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/json.hpp b/common/json.hpp index 42cf577e..c6c1c423 100644 --- a/common/json.hpp +++ b/common/json.hpp @@ -1948,7 +1948,7 @@ class lexer /// return the locale-dependent decimal point static char get_decimal_point() noexcept { - const auto loc = localeconv(); + const auto loc = cpt::localeconv(); assert(loc != nullptr); return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); } @@ -8247,7 +8247,7 @@ class serializer @param[in] ichar indentation character to use */ serializer(output_adapter_t s, const char ichar) - : o(std::move(s)), loc(std::localeconv()), + : o(std::move(s)), loc(cpt::localeconv()), thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep)), decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point)), indent_char(ichar), indent_string(512, indent_char) diff --git a/common/strCompat.h b/common/strCompat.h index a8066490..31ebce7c 100644 --- a/common/strCompat.h +++ b/common/strCompat.h @@ -3,6 +3,7 @@ #include +#include #ifdef NO_CPP11_STRING #include @@ -16,6 +17,18 @@ namespace cpt { + static struct lconv* localeconv() + { + #ifdef NO_CPP11_STRING + static struct lconv result; + result.decimal_point = nullptr; + result.thousands_sep = nullptr; + return &result; + #else + return std::localeconv(); + #endif + } + template static std::string to_string(const T& t) {