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

Overlay/function pointers

Hi,
In our project we are using function pointers. After compiling the project, we got "RECURSIVE CALL TO SEGMENT" warning. By selecting OVERLAY (sfname ! *)in BL51, that warnings was removed.
If we add function name in OVERLAY, will it allocate diffrent memory for local variables and function argumants?.
How it is diffrent from by difining same function as rentrant function ?.

Thanks in advance..

Parents
  • Rajesh,

    I believe the general idea is that you can do one of two things. The first is to specify for the compiler which modules it should just skip doing overlaying for altogether. The other method is to take a look at your code and use the OVERLAY directive to help the compiler finish the call-tree that it would be otherwise unable to generate. As for the specifics, you'll have to look in the manual.

    If I could suggest an alternative, however: Could you simply use another function as a "dispatch" function that takes a parameter. For instance, you're using function pointers so that you could do something like:

    functable[i]()
    You could instead to something like
    void dispatcher(unsigned char i) {
      switch(i) {
        case 1:
          a();
          break;
        case 2:
          b();
          break;
       }
    }
    

    This would allow the compiler to deduce the call tree properly (although it does add a bit more overhead). The problem with the methods where you modify the code tree is that if you ever have to modify things in the future, it's very easy to forget to make the necessary corrections and end up with very intermittent and strange problems.

Reply
  • Rajesh,

    I believe the general idea is that you can do one of two things. The first is to specify for the compiler which modules it should just skip doing overlaying for altogether. The other method is to take a look at your code and use the OVERLAY directive to help the compiler finish the call-tree that it would be otherwise unable to generate. As for the specifics, you'll have to look in the manual.

    If I could suggest an alternative, however: Could you simply use another function as a "dispatch" function that takes a parameter. For instance, you're using function pointers so that you could do something like:

    functable[i]()
    You could instead to something like
    void dispatcher(unsigned char i) {
      switch(i) {
        case 1:
          a();
          break;
        case 2:
          b();
          break;
       }
    }
    

    This would allow the compiler to deduce the call tree properly (although it does add a bit more overhead). The problem with the methods where you modify the code tree is that if you ever have to modify things in the future, it's very easy to forget to make the necessary corrections and end up with very intermittent and strange problems.

Children
No data