diff options
-rw-r--r-- | compat/strerror.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/compat/strerror.cpp b/compat/strerror.cpp index 0afb5f7d..303c78be 100644 --- a/compat/strerror.cpp +++ b/compat/strerror.cpp @@ -6,9 +6,12 @@ namespace floormat { StringView get_error_string(ArrayView<char> buf) { -#ifndef _WIN32 -#if defined __GLIBC__ && !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) - char* str = ::strerror_r(errno, buf.data(), buf.size()); +#ifdef _WIN32 + ::strerror_s(buf.data(), buf.size(), errno); + if (buf[0]) + return buf; +#elif defined __GLIBC__ && !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) + char* str { ::strerror_r(errno, buf.data(), buf.size()) }; if (str) return str; #else @@ -17,12 +20,6 @@ StringView get_error_string(ArrayView<char> buf) return buf; #endif -#else - ::strerror_s(buf.data(), buf.size(), errno); - if (buf[0]) - return buf; -#endif - return "Unknown error"_s; }; |