If someone doesn't mind, I'm trying to figure something out. It's probably me just not being on the ball tonight. :) In any case, I've got a program below that's actually 2 program. The first version is at the top of main() and there are a bunch of lines comments out. Having the program with just this first part works -> as in it returns the results after being compiled and run on a Commodore 4032 pet (screen at the end of the email). The second version doesn't work - if you copied and pasted the program below in whole, it would compile as the second version I'm talking about, with the first version commented out as is. This version doesn't work, and gives me the errors I also list at the end of the program. So maybe this is me not being on the ball with C programming, or me being not on the ball with cc65 and some particular aspect of it's design, but... ----- ...in short, why does this work: ----- void (*vibrato_change)() = vib_chg; void (*lfo_change)() = lfo_chg ; void (*command[])() = {vib_chg,lfo_chg }; // gives me an array of pointers to functions ----- and this doesn't: ----- void (*vibrato_change)(); void (*lfo_change)(); vibrato_change = vib_chg; lfo_change = lfo_chg ; void (*command[])() = {vib_chg,lfo_chg }; //Error: Expression expected ---------- THANKS!!!!!! -Chiron ----- sample code below ----- #include #include void vib_chg() { printf("vib -> do me!n"); }//end func void lfo_chg() { printf("lfo - > do me!n"); }//end func int main(){ // works! creates pointers to functions, // then creates array of those pointers to functions //void (*vibrato_change)() = vib_chg; //void (*lfo_change)() = lfo_chg ; //void (*command[])() = {vib_chg,lfo_chg }; //command[0](); //command[1](); //return EXIT_SUCCESS; //}//end main // the following returns errors: (see end of file) // why doesn't this version work? // does it have something to do with declaring functions // and then variables, and then functions again? void (*vibrato_change)(); void (*lfo_change)(); vibrato_change = vib_chg; lfo_change = lfo_chg ; void (*command[])() = {vib_chg,lfo_chg }; command[0](); command[1](); return EXIT_SUCCESS; }//end main /********** results for working program (the one commented out above) as run on a commodore pet *** commodore basic 4.0 *** 31743 bytes free ready. load"array?of?funcs.prg",8,1: searching for array?of?funcs.prg loading ready. run vib -> do me! lfo - > do me! ready. ********** results for non-working programm compile error output: C:6502cc65bin>cl65 -t pet array_of_funcs_ALT.c -o array_of_funcs_ALT.prg array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Warning: Statement has no effect array_of_funcs_ALT.c(52): Error: `;' expected array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Warning: Statement has no effect array_of_funcs_ALT.c(52): Error: `;' expected array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Warning: Statement has no effect array_of_funcs_ALT.c(52): Error: `;' expected array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Warning: Statement has no effect array_of_funcs_ALT.c(52): Error: `;' expected array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Warning: Statement has no effect array_of_funcs_ALT.c(52): Error: `;' expected array_of_funcs_ALT.c(52): Error: Expression expected array_of_funcs_ALT.c(52): Fatal: Too many errors **********/ ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Sat May 15 09:26:41 2010
This archive was generated by hypermail 2.1.8 : 2010-05-15 09:26:44 CEST