Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Action is instantiated and called for initial event #565

Open
stirwl opened this issue Mar 10, 2023 · 0 comments
Open

Wrong Action is instantiated and called for initial event #565

stirwl opened this issue Mar 10, 2023 · 0 comments

Comments

@stirwl
Copy link

stirwl commented Mar 10, 2023

Compiler report an undefined reference error. It was seeking Action1 for initial event and State1.

undefined reference to `void Action1::operator()<boost::ext::sml::v1_1_6::back::initial>(boost::ext::sml::v1_1_6::back::initial const&, State1&) const'

But idle state has no on_entry defined.
Even we want one, shouldn't the default be
void SomeAction::operator()<boost::ext::sml::v1_1_6::back::initial>(boost::ext::sml::v1_1_6::back::initial const&, StateIdle&) const
?

sm.h:

#pragma once
#include <boost/sml.hpp>

namespace sml = boost::sml;


struct next {};

struct State1{int i;
};

struct Action1{
  void operator()(const auto &evt, State1 & s)const;
};

struct hello_world {
  auto operator()() const {
    using namespace sml;
    return make_transition_table(
      *"idle"_s + event<next>  = state<State1>,
       state<State1> + sml::on_entry<_> /Action1(),
       state<State1> + event<next>  = X
    );
  }
};

sm.cpp:

#include "sm.h"

void Action1::operator()(const auto &evt, State1 &s) const
{
}

main.cpp:

#include "sm.h"
//#include "sm.cpp" //will be fine with this line
int main()
{
  using namespace sml;

  sm<hello_world> sm;
}

sm.zip

Error msg:

$ g++ -std=c++20 main.cpp sm.cpp
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
 D:\msys64\tmp\ccqXGsRK.o:main.cpp:(.text$_ZN5boost3ext3sml6v1_1_65front4callINS2_4back8on_entryINS5
_1_ENS5_7initialEEENS2_3aux9type_listIJRKS8_R6State1EEENS5_9no_policyEE7executeINSA_12zero_wrapperI7
Action1vEENS5_7sm_implINS5_9sm_policyI11hello_worldJEEEEENSA_4poolIJSF_EEENSS_IJSR_EEEEEDaT_RKS9_RT0
_RT1_RT2_[_ZN5boost3ext3sml6v1_1_65front4callINS2_4back8on_entryINS5_1_ENS5_7initialEEENS2_3aux9type
_listIJRKS8_R6State1EEENS5_9no_policyEE7executeINSA_12zero_wrapperI7Action1vEENS5_7sm_implINS5_9sm_p
olicyI11hello_worldJEEEEENSA_4poolIJSF_EEENSS_IJSR_EEEEEDaT_RKS9_RT0_RT1_RT2_]+0x61): undefined refe
rence to `void Action1::operator()<boost::ext::sml::v1_1_6::back::initial>(boost::ext::sml::v1_1_6::
back::initial const&, State1&) const'
collect2.exe: error: ld returned 1 exit status
@stirwl stirwl changed the title template instantiate issue: struct action with event and state as parameter is complant can't find reference if the action is defined in standalone cpp Wrong Action is instantiated and called for initial event Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant