boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.1k stars 173 forks source link

Windows compile error #585

Open rafaelBauer opened 11 months ago

rafaelBauer commented 11 months ago

Expected Behavior

Previously it was compiling in Windows using clang-cl 13.

Actual Behavior

Failing with message: 'boost::sml::back::policies::thread_safe<std::recursive_mutex>::create_lock()::lock_guard::~lock_guard()::lock_guard::lock_' is not a member of class 'lock_guard' ~lock_guard() { lock_.unlock(); }

Steps to Reproduce the Problem

Compile with clang-cl 13

Specifications

Alex0vSky commented 8 months ago

So that we can solve the problem, we need to look at the source code that causes the error and the compilation options.

If the source code is not provided, the issue may be closed soon - a minimally reproducible example has not been provided in full.

Yes, it can be just

#include "sml.hpp"
void main() {}

If we look deeper, then maybe here error:

    struct lock_guard {
      constexpr explicit lock_guard(TLock &lock) : lock_{lock} { lock_.lock(); }
      ~lock_guard() { lock_.unlock(); }
      TLock &lock_;
    };

and solution is declare member lock_ before using it.

    struct lock_guard {
      TLock &lock_;
      constexpr explicit lock_guard(TLock &lock) : lock_{lock} { lock_.lock(); }
      ~lock_guard() { lock_.unlock(); }
    };

But declare before use rule not required inside a class SO