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

How to solove warning recursive call to a constant

I have following codes:

void fun1(unsigned char *msg);

void fun2()
{
fun1("ssss");
}
void fun3()
{
}
code void (*func_array[])()={fun2, fun3};

void fun1( unsigned char *msg)
{
(*func_array[1])();
}

void main()
{
(*fun_array[0])();
}

when compiling, i got the following message
*** WARNING L13: RECURSIVE CALL TO SEGMENT
SEGMENT: ?CO?HELLO

Could you please tell me how to solve it? Thanks a lot!

Parents
  • Thank you all guys!
    I cut and paste part of my codes and solution here. HOPE that you still keep one eye on that, and any suggestion is very welcome!

    The situation is the codes are not only intended for C51, but also for other processor! I prefer a general structure for all platforms, and It seem that using two function pointer tables is a good way.

    Firstly, I have the following data structure for function pointer tables.

    …….
    typedef Bool (*FnDrawing)(Void);
    typedef Void (*FnDrawed)(Void);
    typedef Bool (*FnProcessingKey)(Void);
    typedef Void (*FnProcessedKey)(Void);
    ……….
    
    typedef struct tagStruct
    {
        …………………..
        FnProcessingKey            fnProcessingKey;
        FnProcessedKey             fnProcessedKey;
        FnDrawing           fnDrawing;
        FnDrawed            fnDrawed;
       …………………
    } nuStruct;
    typedef nuStruct * RPnuStruct;
    

    And then I have several function pointer tables.
    Code nuStruct MainStruct =
    {
    …………..
        MainProcessingKey,
        MainProcessedKey,
        MainDrawing,
        MainDrawed,
    …………………….
    };
    
    Code nuStruct TnuStruct =
    {
        …………..,
        TProcessingKey,
        TProcessedKey,
        TDrawing,
        TDrawed,
    ………………
    };
    ……
    


    Base on that, I construct another table
    Code nuStruct * Code c_nuTable[] =
    {
               ……………….
    	&MainnuStruct,
                ……………
    	&TnuStruct,
    	…………..
    };
    


    Depending on different situation, I will select different function from nuStruct to run. Unlucky, in subroutine of some functions of table such as TProcessedKey , I need to look up the table again! So recursive call problem comes out.


    Now my solution is


    Use overlay directive to delete reference between LOOK-UP TABLE and its caller, and then add reference between each function manually! It is a very trial task which costs me half a day, but now seem it works!

Reply
  • Thank you all guys!
    I cut and paste part of my codes and solution here. HOPE that you still keep one eye on that, and any suggestion is very welcome!

    The situation is the codes are not only intended for C51, but also for other processor! I prefer a general structure for all platforms, and It seem that using two function pointer tables is a good way.

    Firstly, I have the following data structure for function pointer tables.

    …….
    typedef Bool (*FnDrawing)(Void);
    typedef Void (*FnDrawed)(Void);
    typedef Bool (*FnProcessingKey)(Void);
    typedef Void (*FnProcessedKey)(Void);
    ……….
    
    typedef struct tagStruct
    {
        …………………..
        FnProcessingKey            fnProcessingKey;
        FnProcessedKey             fnProcessedKey;
        FnDrawing           fnDrawing;
        FnDrawed            fnDrawed;
       …………………
    } nuStruct;
    typedef nuStruct * RPnuStruct;
    

    And then I have several function pointer tables.
    Code nuStruct MainStruct =
    {
    …………..
        MainProcessingKey,
        MainProcessedKey,
        MainDrawing,
        MainDrawed,
    …………………….
    };
    
    Code nuStruct TnuStruct =
    {
        …………..,
        TProcessingKey,
        TProcessedKey,
        TDrawing,
        TDrawed,
    ………………
    };
    ……
    


    Base on that, I construct another table
    Code nuStruct * Code c_nuTable[] =
    {
               ……………….
    	&MainnuStruct,
                ……………
    	&TnuStruct,
    	…………..
    };
    


    Depending on different situation, I will select different function from nuStruct to run. Unlucky, in subroutine of some functions of table such as TProcessedKey , I need to look up the table again! So recursive call problem comes out.


    Now my solution is


    Use overlay directive to delete reference between LOOK-UP TABLE and its caller, and then add reference between each function manually! It is a very trial task which costs me half a day, but now seem it works!

Children