From 694264427f55bc6f44c6284c3a1ad223169e851e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 22 Oct 2021 12:28:03 +0200 Subject: [PATCH] Merge bitcoin/bitcoin#23335: refactor: include a missing header in fs.cpp 077a875d94b51e3c87381133657be98989c8643e refactor: include a missing 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::max(), std::numeric_limits::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::max(), std::numeric_limits::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::max(), std::numeric_limits::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::max(), std::numeric_limits::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::max(), std::numeric_limits::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::max(), std::numeric_limits::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::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 --- src/fs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fs.cpp b/src/fs.cpp index 5a75c6317e..0782961a45 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -14,6 +14,7 @@ #define NOMINMAX #endif #include +#include #include #endif