aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-10-22 12:28:03 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-10-22 12:28:06 +0200
commit4833d1fdf39fb4e3dc45b76960b769d641eca4b8 (patch)
tree78ffc1c0c8b72cfbf14e70c0558a7b379ffa34fb
parent9469ffcb17f0018b61f85f835cc8b49370d26d1f (diff)
parent077a875d94b51e3c87381133657be98989c8643e (diff)
downloadbitcoin-4833d1fdf39fb4e3dc45b76960b769d641eca4b8.tar.xz
Merge bitcoin/bitcoin#23335: refactor: include a missing <limits> header in fs.cpp
077a875d94b51e3c87381133657be98989c8643e refactor: include a missing <limits> header in fs.cpp (Joan Karadimov) Pull request description: I get this compilation error on versions `0.21.1` and `22.0`: ``` fs.cpp: In member function 'bool fsbridge::FileLock::TryLock()': fs.cpp:123:89: error: 'numeric_limits' is not a member of 'std' 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^~~~~~~~~~~~~~ fs.cpp:123:109: error: expected primary-expression before '>' token 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^ fs.cpp:123:112: error: '::max' has not been declared; did you mean 'std::max'? 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^~~ | std::max In file included from C:/dev/msys64/mingw64/include/c++/11.2.0/bits/char_traits.h:39, from C:/dev/msys64/mingw64/include/c++/11.2.0/string:40, from ./fs.h:9, from fs.cpp:5: C:/dev/msys64/mingw64/include/c++/11.2.0/bits/stl_algobase.h:300:5: note: 'std::max' declared here 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ fs.cpp:123:124: error: 'numeric_limits' is not a member of 'std' 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^~~~~~~~~~~~~~ fs.cpp:123:144: error: expected primary-expression before '>' token 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^ fs.cpp:123:147: error: '::max' has not been declared; did you mean 'std::max'? 123 | if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) { | ^~~ | std::max In file included from C:/dev/msys64/mingw64/include/c++/11.2.0/bits/char_traits.h:39, from C:/dev/msys64/mingw64/include/c++/11.2.0/string:40, from ./fs.h:9, from fs.cpp:5: C:/dev/msys64/mingw64/include/c++/11.2.0/bits/stl_algobase.h:300:5: note: 'std::max' declared here 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ ``` It appears that `std::numeric_limits<T>::max` is used without the `limits` header being included. Probably on other STL implementations it's included transitively, but not in the one in MinGW. Including it fixes the compilation problem. Environment: OS: Windows 10 Compiler: gcc 11.2.0 Qt: 5.15.2 (included in msys2) Using the latest mingw w64 shipped with msys2. ACKs for top commit: fanquake: ACK 077a875d94b51e3c87381133657be98989c8643e - Thanks. hebasto: ACK 077a875d94b51e3c87381133657be98989c8643e Tree-SHA512: 2289cb72fa3a28470f4250833be66079482d1392189b1e4679330dad109a8ae67b1d6d51cb635dbc1947c00c6c4cfbc4d7c9ae02269b932cfa1475583adaf73d
-rw-r--r--src/fs.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/fs.cpp b/src/fs.cpp
index 8cae7f32c6..7a99444eef 100644
--- a/src/fs.cpp
+++ b/src/fs.cpp
@@ -16,6 +16,7 @@
#define NOMINMAX
#endif
#include <codecvt>
+#include <limits>
#include <windows.h>
#endif