From 0db935b602264743f5fef14da64760f52de7bb24 Mon Sep 17 00:00:00 2001 From: Esonhugh Date: Wed, 27 Dec 2023 11:19:59 +0800 Subject: [PATCH] fix: let __DARWIN_C as an exception --- toml/exception.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/toml/exception.hpp b/toml/exception.hpp index 1367948..81c6401 100644 --- a/toml/exception.hpp +++ b/toml/exception.hpp @@ -37,7 +37,13 @@ inline std::string str_error(int errnum) { return std::string(buf.data()); } -#elif (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) || ( defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200112L ) // macos or POSIX +#elif defined(_GNU_SOURCE) && !(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200112L ) + constexpr std::size_t bufsize = 256; + std::array buf; + buf.fill('\0'); + const char* result = strerror_r(errnum, buf.data(), bufsize); + return std::string(result); +#elif (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) || ( defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200112L ) // macOS constexpr std::size_t bufsize = 256; std::array buf; buf.fill('\0'); @@ -50,12 +56,6 @@ inline std::string str_error(int errnum) { return std::string(buf.data()); } -#elif defined(_GNU_SOURCE) - constexpr std::size_t bufsize = 256; - std::array buf; - buf.fill('\0'); - const char* result = strerror_r(errnum, buf.data(), bufsize); - return std::string(result); #else // fallback return std::strerror(errnum); #endif