error C3203: ‘UniqueLock’ #28229

issue alxppv openend this issue on August 7, 2023
  1. alxppv commented at 10:51 am on August 7, 2023: none

    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

  2. hebasto commented at 11:04 am on August 7, 2023: member

    When compiling the libbitcoin_node library in Microsoft Visual Studio Community 2019,

    Only Visual Studio 2022 is supported.

  3. alxppv commented at 11:29 am on August 7, 2023: none

    Only Visual Studio 2022 is supported.

    It’s probably all about habit. I don’t see any problems. VS2019 supports ISO C++20 Standard. Except for the described error, everything compiles. All tests pass correctly.

  4. MarcoFalke commented at 11:32 am on August 7, 2023: member
    In any case this seems to be an upstream bug with your msvc not implementing the C++ standard correctly. You can try upgrading to Visual Studio 2022, but I am not sure what we are supposed to do here?
  5. MarcoFalke added the label Windows on Aug 7, 2023
  6. MarcoFalke added the label Upstream on Aug 7, 2023
  7. MarcoFalke added the label Questions and Help on Aug 7, 2023
  8. alxppv commented at 11:55 am on August 7, 2023: none

    upgrading to Visual Studio 2022, but I am not sure what we are supposed to do here?

    In general, this issue is informative. Maybe someone tried, got an error and did not understand further. But the reproducibility of this error on VS2019 is interesting.

  9. hebasto commented at 11:56 am on August 7, 2023: member

    It’s probably all about habit. I don’t see any problems. VS2019 supports ISO C++20 Standard.

    More details are available here: #24531.

  10. fanquake commented at 12:06 pm on August 7, 2023: member

    but I am not sure what we are supposed to do here?

    Yea, nothing we can do about broken software that we explicitly don’t support. Closing for now. Discussion can continue if needed.

  11. fanquake closed this on Aug 7, 2023


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me