[statechart] - templated asynchronous_state_machine compilation problem
Hello, I've a problem to compile (gcc- 4.1.2) a templated asynchronous state machine. error: expected `)' before 'ctx' template< typename streamT > struct proto; template< typename streamT > class presentation : public sc::asynchronous_state_machine< presentation< streamT >, proto< streamT >, sc::fifo_scheduler<>
{ public: typedef streamT stream_type; presentation( my_context ctx) : my_base( ctx) // error: expected `)' before 'ctx' {} }; Thanks, Oliver
Hi Oliver Oliver.Kowalke@qimonda.com wrote:
Hello, I've a problem to compile (gcc- 4.1.2) a templated asynchronous state machine.
error: expected `)' before 'ctx'
MSVC 7.1 produces an almost identical diagnostic. This is a well-known C++ "problem". As soon as the deriving class is a template you need to fully qualify base class typedefs. The following works on MSVC7.1: #include <boost/statechart/asynchronous_state_machine.hpp> #include <boost/statechart/simple_state.hpp> #include <boost/statechart/fifo_scheduler.hpp> namespace sc = boost::statechart; template< typename streamT > struct proto; template< typename streamT > class presentation : public sc::asynchronous_state_machine< presentation< streamT >, proto< streamT > > { typedef typename sc::asynchronous_state_machine< presentation< streamT >, proto< streamT > > base_type; public: // **** HERE **** presentation( typename base_type::my_context ctx ) : base_type( ctx ) {} }; template< typename streamT > struct proto : sc::simple_state< proto, presentation< streamT > > {}; int main() { sc::fifo_scheduler<> scheduler; sc::fifo_scheduler<>::processor_handle presentation_handle = scheduler.create_processor< presentation< int > >(); scheduler.initiate_processor( presentation_handle ); scheduler(); return 0; } HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Oliver.Kowalke@qimonda.com