[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
  • It sounds like you have declared a table of function pointers in code space and some other variables in code space in the same file (SERIAL_CMD2.C).

    The error message

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

    says that FUNC_4 is recursively accessing the constant segment (in code space). That means that FUNC_4 is accessed from the constant segment (which it is from the serial_table) and FUNC_4 accesses some stuff in the constant segment (which it may do).

    There are a number of ways to avoid this problem. The easiest is to move the table of function pointers into a separate file all by itself.

    There is an application note that covers everything you should know about function pointers in C51 because they are tricky.

    http://www.keil.com/appnotes/docs/apnt_129.asp

    Jon

Reply
  • It sounds like you have declared a table of function pointers in code space and some other variables in code space in the same file (SERIAL_CMD2.C).

    The error message

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

    says that FUNC_4 is recursively accessing the constant segment (in code space). That means that FUNC_4 is accessed from the constant segment (which it is from the serial_table) and FUNC_4 accesses some stuff in the constant segment (which it may do).

    There are a number of ways to avoid this problem. The easiest is to move the table of function pointers into a separate file all by itself.

    There is an application note that covers everything you should know about function pointers in C51 because they are tricky.

    http://www.keil.com/appnotes/docs/apnt_129.asp

    Jon

Children
More questions in this forum