Windows XP compatibility

pull/306/head
emazv72 9 years ago
parent 1f1f6a5f3b
commit a215f5922f

@ -30,6 +30,14 @@
#include <share.h> #include <share.h>
#endif #endif
#define SPDLOG_SECURE_API
#ifdef __MINGW32__
#ifndef MINGW_HAS_SECURE_API
#undef SPDLOG_SECURE_API
#endif
#endif
#include <sys/types.h> #include <sys/types.h>
#elif __linux__ #elif __linux__
@ -333,10 +341,12 @@ inline std::string filename_to_str(const filename_t& filename)
// Return errno string (thread safe) // Return errno string (thread safe)
inline std::string errno_str(int err_num) inline std::string errno_str(int err_num)
{ {
#ifdef SPDLOG_SECURE_API
char buf[256]; char buf[256];
SPDLOG_CONSTEXPR auto buf_size = sizeof(buf); SPDLOG_CONSTEXPR auto buf_size = sizeof(buf);
#ifdef _WIN32 #ifdef _WIN32
if(strerror_s(buf, buf_size, err_num) == 0) if(strerror_s(buf, buf_size, err_num) == 0)
return std::string(buf); return std::string(buf);
else else
@ -353,8 +363,10 @@ inline std::string errno_str(int err_num)
#else // gnu version (might not use the given buf, so its retval pointer must be used) #else // gnu version (might not use the given buf, so its retval pointer must be used)
return std::string(strerror_r(err_num, buf, buf_size)); return std::string(strerror_r(err_num, buf, buf_size));
#endif #endif
#else
return std::to_string(err_num);
#endif
} }
} //os } //os
} //details } //details
} //spdlog } //spdlog

Loading…
Cancel
Save