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

Recursive Function call

I want to use the recursive function call but i get warning message "Warning L13: Recursive call to segment" though i had declared the funcion as "reentrant".

For example my code is like this,

case 1:

void main(void)
  {
     start();
  }

void start(void) reentrant
  {
    .
    .
    some codes are here
    .
  }

 .
 .   //Many functions are here doing different tasks
 .
 .
 .

void DeivceID(void)
  {
    if(check for some condition)
     start();
    else
      do something;
  }

after executing the main function only i come to function call start() but i dont know why the warning message is coming.

case 2:


Considering the same example above instead of using start function i tried to use the main function as reentrant but now the warning message was "warning L10:Cannot find the root segment". And i couldnt execute the program. The program is getting downloaded but is not executing. I dont know why the compiler acts in a two different manner. Can anybody say what's the problem is?

  • Before using reentrant functions on an 8051, you need to be certain that you understand all the issues.

    Be sure to read the whole manual page and the linked knowledgebase articles:

    http://www.keil.com/support/man/docs/c51/c51_le_reentrantfuncs.htm

    Pay particular attention to this note:

    "The reentrant stack simulation architecture is inefficient, but necessary due to a lack of suitable addressing methods available on the 8051. For this reason, use reentrant functions sparingly."

    Having done that, you can properly evaluate whether reentrant functions are really necessary to your application...