From 6f8e36ac3dd7d3e0587297d6ecdc8e1b19a863b6 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 6 Dec 2015 17:33:47 +0100 Subject: [PATCH] fixes #136 --- README.md | 1 + src/json.hpp | 20 +++++++++++++++++++- src/json.hpp.re2c | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 76c32d4470..0a382e7eb8 100644 --- a/README.md +++ b/README.md @@ -380,6 +380,7 @@ I deeply appreciate the help of the following people. - [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation. - [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference. - [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support. +- [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK. Thanks a lot for helping out! diff --git a/src/json.hpp b/src/json.hpp index 1e3cd11fde..aa262ae3fe 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -70,6 +70,25 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. using ssize_t = SSIZE_T; #endif +// workaround for Android NDK (see https://github.com/nlohmann/json/issues/136) +#ifdef __ANDROID__ +namespace std +{ +template +std::string to_string(T v) +{ + std::ostringstream ss; + ss << v; + return ss.str(); +} + +inline long double strtold(const char* str, char** str_end) +{ + return strtod(str, str_end); +} +} +#endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann @@ -6009,7 +6028,6 @@ class basic_json 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; - if ((m_limit - m_cursor) < 5) { yyfill(); // LCOV_EXCL_LINE; diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 84559240b4..88391d61db 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -70,6 +70,25 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. using ssize_t = SSIZE_T; #endif +// workaround for Android NDK (see https://github.com/nlohmann/json/issues/136) +#ifdef __ANDROID__ +namespace std +{ +template +std::string to_string(T v) +{ + std::ostringstream ss; + ss << v; + return ss.str(); +} + +inline long double strtold(const char* str, char** str_end) +{ + return strtod(str, str_end); +} +} +#endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann