Boost logo

Boost Users :

Subject: [Boost-users] State machines and undedefined symbols
From: s_a_white_at_[hidden]
Date: 2010-03-09 19:58:53


Hi,

I've inherited some code that currently compiles and runs under Linux (gcc 4.2.1) and am looking to switch to Windows using the vs 2003.

Unfortunately the code fails to compile with undefined symbols. An example of the code is as follows:

#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>

#include <iostream>

namespace sc = boost::statechart;

struct EvStartStop : sc::event< EvStartStop > {};
struct EvReset : sc::event< EvReset > {};

struct Active;
struct Stopped;
struct Running;

struct StopWatch : sc::state_machine< StopWatch, Active > {};

struct Active : sc::simple_state< Active, StopWatch, Stopped >
{
  typedef sc::transition< EvReset, Active > reactions;
};

struct Stopped : sc::simple_state< Stopped, Active >
{
  typedef sc::transition< EvStartStop, Running > reactions;
};

int main()
{
  return 0;
}

I'm aware that the code is incomplete as Running is only forward declared. It is provided this way since the real model under Linux is broken up across multiple headers rather than all being in one header.

Under Linux the above code compiles without an issue but vs 2003 complains about Running being undefined. Removing sc::transition< EvStartStop, Running > makes the compilation problem disappear. A similiar issue exists for Windows if Running was defined but uses an inner state that was only foward declared. Again Linux seems to have no problems.

Can anyone suggest if what is being done here is broken under vs 2003, or should not be allowed under gcc? Are there workarounds for the boost headers for vs 2003 or recommendations to allow splitting the state machine across multiple headers?

Best Regards,
Simon



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net