Can anyone help me write some C code to implement a state machine? I'm using the PCM compiler from CCS and want code that compiles to a computed jump. I could write in-line assembler of course, but need the code to be portable. The following works ok on a PC, compiled with Borland C++ 3.1, where I use the number of command-line arguments to derive a state number: --------------------------- #include void state0( void ) ; // state function prototypes void state1( void ) ; void state2( void ) ; const void (*state_pt[])() = { state0 , state1 , state2 } ; // array of pointers to void functions void main( int argc ) { int state ; state = argc - 1 ; (*state_pt[state])() ; } void state0(void) { printf( "This is state 0 \n" ) ; } void state1(void) { printf( "This is state 1 \n" ) ; } void state2(void) { printf( "This is state 2 \n" ) ; } --------------------------- Although this runs fine in Borland C, the compiler gives me a warning "Call to function without prototype" for: (*state_pt[state])() ; I don't know why I get this warning, as I already declared state_pt (as a global). However,the real problem occurs when I try to compile similar code under PCM (adapted for the PIC environment -- no argc, etc). This compiler doesn't like... const void (*state_pt[])() = { state0 , state1 , state2 } ; ... and gives error msg: "Line 9 Error # 34 Unknown type." Does anyone know what's going wrong? Any help appreciated. Regards, Doug Manzer