From a12a09b10264294d2b1d8c8e7901e328fce646c0 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 16 Jun 2024 14:51:51 +0900 Subject: [PATCH] fix: use sscanf_s if available --- include/toml11/types.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/toml11/types.hpp b/include/toml11/types.hpp index 9307b1e8..42583dc6 100644 --- a/include/toml11/types.hpp +++ b/include/toml11/types.hpp @@ -15,6 +15,7 @@ #include #include +#include namespace toml { @@ -155,7 +156,11 @@ read_int(const std::string& str, const source_location src, const std::uint8_t b inline result read_hex_float(const std::string& str, const source_location src, float val) { +#if defined(_MSC_VER) && ! defined(__clang__) + const auto res = std::sscanf_s(str.c_str(), "%a", std::addressof(val)); +#else const auto res = std::sscanf(str.c_str(), "%a", std::addressof(val)); +#endif if(res != 1) { return err(make_error_info("toml::parse_floating: " @@ -167,7 +172,11 @@ read_hex_float(const std::string& str, const source_location src, float val) inline result read_hex_float(const std::string& str, const source_location src, double val) { +#if defined(_MSC_VER) && ! defined(__clang__) + const auto res = std::sscanf_s(str.c_str(), "%la", std::addressof(val)); +#else const auto res = std::sscanf(str.c_str(), "%la", std::addressof(val)); +#endif if(res != 1) { return err(make_error_info("toml::parse_floating: "