while using Keil8.04 compiling and link, there is a fatal error: *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISP_MOTORSETUP?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?_LCD_SHOWCHAR?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?_LCD_SHOWHZ?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?_LCD_SHOWSTR?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISP_CYCLICSETUP?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISP_MOTORRUNSETUI?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISP_GENERALSETUI?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISPAR_TIME?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISPAR_STARTTIME?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?DISPAR_ALARMTEMP?MAIN *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?MAIN CALLER: ?PR?SETUP_MOTORRUNPAR?MAIN *** FATAL ERROR L232: APPLICATION CONTAINS TOO MANY RECURSIONS Target not created.
I don't konw why, if there are some error while use function pointer or the pro struct include too many layers? waiting for your idears. this problem has pazzled me several days. If mesessary, i can upload my code for you !
instead of (abbreviated)
//uchar Setup_MotorPar(void); uchar Setup_CyclicPar(void); {14, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4, Setup_MotorPar }, {16, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6, Setup_CyclicPar }, do this: uchar Setup_MotorPar(void); uchar Setup_CyclicPar(void); #define SMP 1 // Setup_MotorPar(void); #define SCP 2 // Setup_CyclicPar(void); {14, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4, SMP }, {16, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6, SCP }, then in the routine: switch (table.offset) // whatever it is { case SMP: Setup_MotorPar(); break; case SCP: Setup_CyclicPar(); break; }
had this been another processor than the '51 I might very well have done like you, but the '51 has its pecularities and working with them is so much more fruitful that trying to fight them
Erik
Thanks for you reply. That is a selectable way to avoid function pointer, in cost, there should be another 'switch-case' for my menu. I had modified the struct arry, just like below:
<per> code struct fuc_index Fuc_table[--]={ .. {14, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4, Setup_MotorPar }, {16, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6, Setup_CyclicPar }, .. };
I just modified 'code' to 'xdata',and the recursion warnning were all disappeared, but while the program running, and calling function using function pointer, no error but it was a Ilegal Pointer which was pointed by keil, I am not very clearly about it, If the storing way of the constant struct which concluds constant function pointer lead to the error?
That is a selectable way to avoid function pointer
you are using TWO things that the '51 architecture is singularily unsuited for "function pointers' and "recursive calls".
What I suggested was to get rid of BOTH.
If 'programmers convenience' is more important to you that 'process effiecienmcy' then what you are doing is just fine, but the overhead of using these twu things that the '51 must be "wrangled into" performing is very likely to get you on trouble some day.
The case of a "working code" falling apart the day you are asked to make a "nominal addition" is not unheard of.
"I just modified 'code' to 'xdata'"
That can't possibly work!
A function pointer obviously has to point to CODE space, doesn't it?
Note that the tags are 'pre' and '/pre' - not 'per' and '/per' This should be obvious from the preview...