This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[C51] : WHY RECURSIVE CALL TO SEGMENT ?

in c51 i use function pointer :


code void (*serial_tabel []) () ={
func_0, func_1, func_2, func_3,func_4
};

static void func_0 (){
strcpy(SPackData,"ngetit 0");
SendPack ();
}

static void func_1 (){
strcpy(SPackData,"ngetit 1");
SendPack ();
}


static void func_2 (){
strcpy(SPackData,"ngetit 2");
SendPack ();
}

static void func_3 (){
strcpy(SPackData,"ngetit 3");
SendPack ();
}

static void func_4 (){
data byte a,b,d;
a = (byte) atoi(CMD_LOC[1]);
b = (byte) atoi(CMD_LOC[2]);
d = (byte) atoi(CMD_LOC[3]);
SetBaseFrq(d);
strcpy(SPackData,"i love you !");
SendPack ();
}




in func_4 () i get this warning :

*** WARNING L13: RECURSIVE CALL TO SEGMENT
SEGMENT: ?CO?SERIAL_CMD2
CALLER: ?PR?FUNC_4?SERIAL_CMD2

why ?
what mean ?
how reolve ?

Parents
  • "i read all app note and topic about function pointer in c51"

    If you've read all that, then you should now understand why function pointers are so difficult for any 'C' compiler targetted to the 8051 - it is due to a fundamental limitation of the underlying hardware architecture (viz, chronically limited stack space).

    When writing software for embedded systems, you always have to bear in mind the limitations of the target hardware.
    Is it really essential that you use function pointers? Considering the target architecture, and the inherent problems you've already seen, wouldn't another approach be more appropriate?
    Conversely, if function pointers really are absolutely essential, is this an appropriate target?

    Have you considered making your functions reentrant? It might help, but at a big cost in performance.

Reply
  • "i read all app note and topic about function pointer in c51"

    If you've read all that, then you should now understand why function pointers are so difficult for any 'C' compiler targetted to the 8051 - it is due to a fundamental limitation of the underlying hardware architecture (viz, chronically limited stack space).

    When writing software for embedded systems, you always have to bear in mind the limitations of the target hardware.
    Is it really essential that you use function pointers? Considering the target architecture, and the inherent problems you've already seen, wouldn't another approach be more appropriate?
    Conversely, if function pointers really are absolutely essential, is this an appropriate target?

    Have you considered making your functions reentrant? It might help, but at a big cost in performance.

Children
No data