From 160ad58459c18bb3311bdc8d2cada1c56c1b08e3 Mon Sep 17 00:00:00 2001 From: Sundaram Ramaswamy Date: Sat, 26 Nov 2022 05:34:52 +0530 Subject: [PATCH] Fix MINGW32 errors and warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Include `share.h` for `_SH_DENYNO`’s definition * Define `NOMINMAX` only if not already defined; MINGW warns of redefinition since `bits/os_defines.h` included by `` already defines it * Use C++11 `thread_local` instead of the non-standard option of `__declspec(thread)` [1] [1]: https://learn.microsoft.com/en-us/cpp/cpp/thread?view=msvc-170 --- loguru.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/loguru.cpp b/loguru.cpp index 7eaadb7..977a77a 100644 --- a/loguru.cpp +++ b/loguru.cpp @@ -52,6 +52,7 @@ #ifdef _WIN32 #include + #include #define localtime_r(a, b) localtime_s(b, a) // No localtime_r with MSVC, but arguments are swapped for localtime_s #else @@ -127,7 +128,9 @@ #define _WIN32_WINNT 0x0502 #endif #define WIN32_LEAN_AND_MEAN - #define NOMINMAX + #ifndef NOMINMAX + #define NOMINMAX + #endif #include #endif @@ -1034,7 +1037,7 @@ namespace loguru // Where we store the custom thread name set by `set_thread_name` char* thread_name_buffer() { - __declspec( thread ) static char thread_name[LOGURU_THREADNAME_WIDTH + 1] = {0}; + thread_local static char thread_name[LOGURU_THREADNAME_WIDTH + 1] = {0}; return &thread_name[0]; } #endif // LOGURU_WINTHREADS