Describe Hi all, Bitcoin fails to build on MSVC due to waring c4858. Could you help look? Expected behavior Build successfully.
Actual behavior F:\gitP\bitcoin\bitcoin\src\sync.h(168): error C2220: the following warning is treated as an error F:\gitP\bitcoin\bitcoin\src\sync.h(166): note: while compiling class template member function ‘bool UniqueLock<_Ty,std::unique_lock>::TryEnter(const char *,const char *,int)’ with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\sync.h(179): note: see reference to function template instantiation ‘bool UniqueLock<_Ty,std::unique_lock>::TryEnter(const char *,const char *,int)’ being compiled with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\net.h(822): note: see reference to class template instantiation ‘UniqueLock<_Ty,std::unique_lock>’ being compiled with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\sync.h(168): warning C4858: discarding return value: This function returns whether the operation succeeded in modifying object state. It is dangerous to ignore the return value. Detail log Uploading build (3).log…
To reproduce
- git clone https://github.com/bitcoin/bitcoin F:\gitP\bitcoin\bitcoin
- cd F:\gitP\bitcoin\bitcoin\build_msvc
- py -3 msvc-autogen.py
- cd F:\gitP\bitcoin\tools\vcpkg
- git -C “F:\gitP\bitcoin\tools\vcpkg” clean -xdf 2>&1
- bootstrap-vcpkg.bat 2>&1
- set path=%cd%;%path%
- cd F:\gitP\bitcoin\bitcoin\build_msvc
- msbuild /m /p:Platform=x64 /p:Configuration=Release bitcoin.sln /t:Rebuild 2>&1
System information VS version: VS2019 (16.11.11) Operating system: windows server 2019 the commit of Bitcoin we use is 5174a13
workaround I modified the common.init.vcxproj.in file of this text like below to solve this issue: <DisableSpecificWarnings>4018;4244;4267;4334;4715;4805;4834</DisableSpecificWarnings> to be: <DisableSpecificWarnings>4018;4244;4267;4334;4715;4805;4834;4858</DisableSpecificWarnings>