Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
When compiling the libbitcoin_node library in Microsoft Visual Studio Community 2019, Version 16.11.28 got error C3203: ‘UniqueLock’: unspecialized class template can’t be used as a template argument for template parameter ‘_Ty’, expected a real type in the validationinterface.cpp file, code section:
template<typename F> void Iterate(F&& f) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
{
WAIT_LOCK(m_mutex, lock);
for (auto it = m_list.begin(); it != m_list.end();) {
++it->count;
{
REVERSE_LOCK(lock);
f(*it->callbacks);
}
it = --it->count ? std::next(it) : m_list.erase(it);
}
}
line:
REVERSE_LOCK(lock);
REVERSE_LOCK macro in sync.h file:
#define REVERSE_LOCK(g) typename std::decay<decltype(g)>::type::reverse_lock UNIQUE_NAME(revlock)(g, #g, __FILE__, __LINE__)
Expected behaviour
The compilation problem was solved by adding a macro:
#define REVERSE_LOCK_(g) typename UniqueLock<Mutex>::reverse_lock UNIQUE_NAME(revlock)(g, #g, __FILE__, __LINE__)
with explicit typename UniqueLock<Mutex>::reverse_lock
instead of typename std::decay<decltype(g)>::type::reverse_lock
after which the REVERSE_LOCK(lock)
call is changed to REVERSE_LOCK_(lock)
After compilation, run the test:
test_bitcoin --run_test="validationinterface_tests" -- -checkaddrman=1 -printtoconsole=1
Result:
***No errors detected
Steps to reproduce
Before compiling in VS2019,
in the project configuration file common.init.vcxproj
<PlatformToolset>
tag change to v142
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
v25.0
Operating system and version
Windows 10
Machine specifications
No response