Skip to content

Commit

Permalink
fixes #136
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Dec 6, 2015
1 parent c013223 commit 6f8e36a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
20 changes: 19 additions & 1 deletion src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
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
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
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
Expand Down

0 comments on commit 6f8e36a

Please sign in to comment.