Skip to content

Commit 6f8e36a

Browse files
committed
fixes #136
1 parent c013223 commit 6f8e36a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ I deeply appreciate the help of the following people.
380380
- [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation.
381381
- [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference.
382382
- [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support.
383+
- [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK.
383384

384385
Thanks a lot for helping out!
385386

src/json.hpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
7070
using ssize_t = SSIZE_T;
7171
#endif
7272

73+
// workaround for Android NDK (see https://github.com/nlohmann/json/issues/136)
74+
#ifdef __ANDROID__
75+
namespace std
76+
{
77+
template <typename T>
78+
std::string to_string(T v)
79+
{
80+
std::ostringstream ss;
81+
ss << v;
82+
return ss.str();
83+
}
84+
85+
inline long double strtold(const char* str, char** str_end)
86+
{
87+
return strtod(str, str_end);
88+
}
89+
}
90+
#endif
91+
7392
/*!
7493
@brief namespace for Niels Lohmann
7594
@see https://github.com/nlohmann
@@ -6009,7 +6028,6 @@ class basic_json
60096028
64, 64, 64, 64, 64, 64, 64, 64,
60106029
64, 64, 64, 64, 64, 64, 64, 64,
60116030
};
6012-
60136031
if ((m_limit - m_cursor) < 5)
60146032
{
60156033
yyfill(); // LCOV_EXCL_LINE;

src/json.hpp.re2c

+19
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
7070
using ssize_t = SSIZE_T;
7171
#endif
7272

73+
// workaround for Android NDK (see https://github.com/nlohmann/json/issues/136)
74+
#ifdef __ANDROID__
75+
namespace std
76+
{
77+
template <typename T>
78+
std::string to_string(T v)
79+
{
80+
std::ostringstream ss;
81+
ss << v;
82+
return ss.str();
83+
}
84+
85+
inline long double strtold(const char* str, char** str_end)
86+
{
87+
return strtod(str, str_end);
88+
}
89+
}
90+
#endif
91+
7392
/*!
7493
@brief namespace for Niels Lohmann
7594
@see https://github.com/nlohmann

0 commit comments

Comments
 (0)