Doug, The PCM complier doesn't allow pointers to functions. See the third paragraph of the first page of the manual. I'm not sure if the ByteCraft version does or not, but this may be one reaons why PCM is $600 cheaper. Ben, Ben, Ben Wirz Check out My Home Page for Great Deals on Bulk Buy's Nitinol Wire, LMD 18200 H Bridge and 10 Mhz PIC 16C84 blw2@cec.wustl.edu http://cec.wustl.edu/~blw2/index.html On Fri, 3 May 1996, Doug Manzer wrote: > 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 >