I am writing a state machine in sketch and get the following error when I compile.
aggregate 'instance_data_t data' has incomplete type and cannot be defined
Here are the associated parts of my code.
typedef enum { INITIAL_STATE, STOP_STATE, GO_STATE, CAUTION_STATE, NUM_STATES } state_t;
typedef struct instance_data instance_data_t; <---------Here is the typedef statement.
typedef state_t state_func_t(instance_data_t *data);
state_t initialize_lights( instance_data_t *data );
state_t stop_traffic( instance_data_t *data );
state_t start_traffic( instance_data_t *data );
state_t caution_traffic( instance_data_t *data );
state_func_t* const state_table[NUM_STATES] = {
initialize_lights, stop_traffic, start_traffic,
caution_traffic
};
state_t run_state( state_t cur_state, instance_data *data ) {
return state_table cur_state ;
};
void setup() {
// pinMode(red,OUTPUT);
// pinMode(yellow,OUTPUT);
// pinMode(green,OUTPUT);
}
void loop() {
state_t cur_state = INITIAL_STATE;
instance_data_t data; <--------------- This is where I get the error!
while( 1 ) {
cur_state = run_state(cur_state, &data );
}
exit;
Any help would be great!
Thanks
Bill