Discussion Forum

problem with recursive function

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Farhan Arshad
Posted
18-Sep-2004 14:29 GMT
Toolset
C51
New! problem with recursive function
hi
I am calling a function recursively.but it overwrite the locale variables of that function. when function returns it overwrite the values.
Regards
FarhanArshad
Read-Only
Author
Jon Ward
Posted
18-Sep-2004 14:49 GMT
Toolset
C51
New! RE: problem with recursive function
Did you declare the function using the reentrant keyword? C51 functions are not reentrant or recursive by default.

Refer to the manual: http://www.keil.com/support/man/docs/c51/c51_le_reentrantfuncs.htm

And to this knowledgebase article: http://www.keil.com/support/docs/1861.htm

Jon
Read-Only
Author
Andy Neil
Posted
18-Sep-2004 15:33 GMT
Toolset
C51
New! RE: problem with recursive function
"I am calling a function recursively.but it overwrite the locale variables of that function."

As Jon says, that is because C51 functions are inherently not reentrant.
It also says so in the Manual.

For details of why this is so, read Application Note 129, Function Pointers in C51:
http://www.keil.com/appnotes/docs/apnt_129.asp

An the knowledgebase article C51 - PROBLEMS WITH FUNCTION POINTERS OVERWRITING VARIABLES:
http://www.keil.com/support/docs/210.htm

Next Thread | Thread List | Previous Thread Start a Thread | Settings