diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index e5c1d01f1..17289481d 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -1066,8 +1066,10 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif if (value == 0) // +-0 { *first++ = '0'; @@ -1076,7 +1078,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 0199b9b59..6c9bbf445 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1525,8 +1525,10 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && static_cast(n) <= static_cast((std::numeric_limits::max)()) && static_cast(static_cast(n)) == static_cast(n)) @@ -1543,7 +1545,9 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } public: diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index cd8152811..7303ca588 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -6278,8 +6278,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec */ friend bool operator==(const_reference lhs, const_reference rhs) noexcept { +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif const auto lhs_type = lhs.type(); const auto rhs_type = rhs.type(); @@ -6344,7 +6346,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } return false; +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 84a70cf59..5d6b72b22 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14826,8 +14826,10 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && static_cast(n) <= static_cast((std::numeric_limits::max)()) && static_cast(static_cast(n)) == static_cast(n)) @@ -14844,7 +14846,9 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } public: @@ -15985,8 +15989,10 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif if (value == 0) // +-0 { *first++ = '0'; @@ -15995,7 +16001,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); @@ -23370,8 +23378,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec */ friend bool operator==(const_reference lhs, const_reference rhs) noexcept { +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif const auto lhs_type = lhs.type(); const auto rhs_type = rhs.type(); @@ -23436,7 +23446,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } return false; +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } /*!