Hi All I have use function pointer array like this main.c uchar i; for(i = 0;i<END_COMMAND;i++) printf("%bu %x\n",i,Func_table[i]); cmd.h typedef void (*Func) (void); void init_func(void); void reset_func(void); void end_command(void); cmd.c Func Func_Table[] = { init_func, reset_func, end_command } void init_func(void){DO_SOMETHING} void reset_func(void){DO_SOMETHING} void end_command(void){DO_SOMETHING} When I run in Keil IDE Debug mode it can trace into code and print correct function address (Ex 0 ff00 1 ff10 2 ff20) ,but when I run into flash,all function address is print zero(ex 0 0 1 0 2 0) so I got reset when use this Func_Table why?? Thanks a lot
First of all, be very wary of using function pointers on 8051s. It can be done, but it should be used sparingly and very carefully. "Thou hast been warnd". The problem at hand is that your printf() statement is wrong. 1) You're trying to print a pointer as if it were a number. That's always a bad idea. The %p format specifier exists for a reason. 2) You're doing this with a function pointer. That's even worse. 3) You're doing printf() debugging in a compiler that comes with a very powerful integrated debugger. That's just a waste of your time.