compile error using gcc 5.4.0 (ubuntu 16.04)
taliesin opened this issue · 4 comments
I get the following compile error for the (unmodified) elevator example:
g++ -c -I ../../include -MMD -Os -std=c++11 -fno-exceptions -fno-rtti -Wall -Wextra -Wctor-dtor-privacy -Wcast-align -Wpointer-arith -Wredundant-decls -Wshadow -Wcast-qual -Wcast-align -pedantic -o motor.o motor.cpp
In file included from motor.cpp:1:0:
../../include/tinyfsm.hpp:235:63: error: specialization of ‘template static void tinyfsm::Fsm::set_initial_state()’ in different namespace [-fpermissive]
template<> void tinyfsm::Fsm< _FSM >::set_initial_state(void) {
^
motor.cpp:62:1: note: in expansion of macro ‘FSM_INITIAL_STATE’
FSM_INITIAL_STATE(Motor, Stopped)
^
../../include/tinyfsm.hpp:96:17: error: from definition of ‘template static void tinyfsm::Fsm::set_initial_state()’ [-fpermissive]
static void set_initial_state();
^
Makefile:90: recipe for target 'motor.o' failed
make: *** [motor.o] Error 1
Any hint appreciated, my C++ template skills seem quite a bit rusty?!
namespace tinyfsm {
FSM_INITIAL_STATE(Motor, Stopped)
}
does the trick, but I still wonder why this was working with a different compiler?
#define FSM_INITIAL_STATE(_FSM, _STATE) \
namespace tinyfsm { \
template<> void tinyfsm::Fsm< _FSM >::set_initial_state(void) { \
current_state_ptr = &_state_instance< _STATE >::value; \
}}
to fix it for all.
It's a compiler bug, see #9
A fix for this is already on the master branch (9d0e1c3), guess I'll release this today.
Just to make sure, could you please report back if this works for your compiler:
https://github.com/digint/tinyfsm/blob/master/include/tinyfsm.hpp
Yes that works, I did the very same thing.
Should have checked the closed issues, sorry for the noise and thanks for the fast response.
Just released tinyfsm-0.3.1, including the fix for gcc < 7.0
Should have checked the closed issues, sorry for the noise and thanks for the fast response.
...should not have closed the issue before releasing...