diff --git a/src/json.hpp b/src/json.hpp index 030d955e0..c0a630e1e 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -29,6 +29,13 @@ #include #include +// enable ssize_t on MinGW +#ifdef __GNUC__ + #ifdef __MINGW32__ + #include + #endif +#endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann @@ -2159,8 +2166,7 @@ class basic_json recursively. Note that - strings and object keys are escaped using escape_string() - - integer numbers are converted to a string before output using - std::to_string() + - integer numbers are converted implictly via operator<< - floating-point numbers are converted to a string using "%g" format @param o stream to write to @@ -2278,9 +2284,10 @@ class basic_json { // 15 digits of precision allows round-trip IEEE 754 // string->double->string - const auto sz = static_cast(std::snprintf(nullptr, 0, "%.15g", m_value.number_float)); + using std::snprintf; + const auto sz = static_cast(snprintf(nullptr, 0, "%.15g", m_value.number_float)); std::vector buf(sz + 1); - std::snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float); + snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float); o << buf.data(); return; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 84f5aaa0f..572690bcb 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -29,6 +29,13 @@ #include #include +// enable ssize_t on MinGW +#ifdef __GNUC__ + #ifdef __MINGW32__ + #include + #endif +#endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann @@ -2159,8 +2166,7 @@ class basic_json recursively. Note that - strings and object keys are escaped using escape_string() - - integer numbers are converted to a string before output using - std::to_string() + - integer numbers are converted implictly via operator<< - floating-point numbers are converted to a string using "%g" format @param o stream to write to @@ -2278,9 +2284,10 @@ class basic_json { // 15 digits of precision allows round-trip IEEE 754 // string->double->string - const auto sz = static_cast(std::snprintf(nullptr, 0, "%.15g", m_value.number_float)); + using std::snprintf; + const auto sz = static_cast(snprintf(nullptr, 0, "%.15g", m_value.number_float)); std::vector buf(sz + 1); - std::snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float); + snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float); o << buf.data(); return; }