diff --git a/interop/src/cpp/DeserializerBase.h b/interop/src/cpp/DeserializerBase.h index 219dcfbe274ab7e2b5adce118c5297f315605455..87fe3fc392bb6d037735247552eabcfecebf361e 100644 --- a/interop/src/cpp/DeserializerBase.h +++ b/interop/src/cpp/DeserializerBase.h @@ -563,12 +563,19 @@ inline void WriteToString(std::string *result, InteropUInt32 value) template <> inline void WriteToString(std::string *result, InteropFloat32 value) { +#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 130300L)) + // to_chars() is not available on older macOS. + char buf[20]; + snprintf(buf, sizeof buf, "%f", value); + result->append(buf); +#else std::string storage; storage.resize(20); // We use to_chars() to avoid locale issues. auto rc = std::to_chars(storage.data(), storage.data() + storage.size(), value); storage.resize(rc.ptr - storage.data()); result->append(storage); +#endif } template <> inline void WriteToString(std::string* result, const InteropBuffer* value) {