loguru
loguru copied to clipboard
Loguru c++ version and mingw64
Hi Sir,
When I use mingw64 to compile my code, the following msg. :
C:\Users\Amber\Desktop\tsn-milestone2\module\lib\loguru\loguru.cpp:117:0: warning: "NOMINMAX" redefined #define NOMINMAX In file included from C:/msys64/mingw64/include/c++/7.3.0/x86_64-w64-mingw32/bits/c++config.h:533:0, from C:/msys64/mingw64/include/c++/7.3.0/utility:68, from C:/msys64/mingw64/include/c++/7.3.0/algorithm:60, from C:\Users\Amber\Desktop\tsn-milestone2\module\lib\loguru\loguru.cpp:29: C:/msys64/mingw64/include/c++/7.3.0/x86_64-w64-mingw32/bits/os_defines.h:45:0: note: this is the location of the previous definition #define NOMINMAX 1
This is a warning msg., but I cannot ensure this will cause some error or not. I include loguru.cpp in CmakeLIst and include loguru.hpp in all my cpp files.
Can I ignore this warning or what can i do??
Thank you.
You can ignore it.
Windows.h
conditionally defines function-like macros for min
and max
- NOMINMAX
is a user-settable define that controls this.
Your compiler is warning about that someone else (in this case a mingw-w64 header) has already defined the macro that Loguru defines in its implementation file. It's commonly set to avoid the min
/max
macros from breaking C++ expressions like std::max(42, 3)
.
To get rid of this warning, Loguru would have to test if the define is set before setting it.
Thank you for your reply. However, I found there has the other warning messages about "No signal handlers" and "'thread' attribute directive ignored [-Wattributes]":
C:\Users\Amber\Desktop\tsn-milestone2\module\lib\loguru\loguru.cpp:1666:4: warning: #warning "No signal handlers on Win32" [-Wcpp] #warning "No signal handlers on Win32" ^~~~~~~
C:\Users\Amber\Desktop\tsn-milestone2\module\lib\loguru\loguru.cpp: In function 'char* loguru::get_thread_name_win32()': C:\Users\Amber\Desktop\tsn-milestone2\module\lib\loguru\loguru.cpp:895:75: warning: 'thread' attribute directive ignored [-Wattributes] __declspec( thread ) static char thread_name[LOGURU_THREADNAME_WIDTH + 1] = {0}; ^
So can I also ingore these msgs?? Thank you for all your assistance, I really appreciate your help. ^^
With MinGW 10.3.0 (MSYS2), I still get
[1/18] Building CXX object CMakeFiles/loguru.dir/third_party/loguru/loguru.cpp.obj
../third_party/loguru/loguru.cpp:132: warning: "NOMINMAX" redefined
132 | #define NOMINMAX
|
In file included from C:/Apps/msys64/mingw64/include/c++/10.3.0/x86_64-w64-mingw32/bits/c++config.h:522,
from C:/Apps/msys64/mingw64/include/c++/10.3.0/utility:68,
from C:/Apps/msys64/mingw64/include/c++/10.3.0/algorithm:60,
from ../third_party/loguru/loguru.cpp:36:
C:/Apps/msys64/mingw64/include/c++/10.3.0/x86_64-w64-mingw32/bits/os_defines.h:45: note: this is the location of the previous definition
45 | #define NOMINMAX 1
|
../third_party/loguru/loguru.cpp: In function 'char* loguru::thread_name_buffer()':
../third_party/loguru/loguru.cpp:1026:75: warning: 'thread' attribute directive ignored [-Wattributes]
1026 | __declspec( thread ) static char thread_name[LOGURU_THREADNAME_WIDTH + 1] = {0};
| ^
Can I disable this warn force?
Perhaps simply deleting NOMINMAX
and adding #include <share.h>
can solve the problem