recursive function depth

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Sunny
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

I have a recursive function in my code I want to configure  the depth of recursive to 20 how can I do the same.  

Sunny

 

 

0 Likes
1 Solution
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @Sunny ,

Can you please share the details of your compiler and IDE version which you are using.

We have provided an example to configure depth of recursive function in compiler:
Compiler: arm-none-eabi-gcc
IDE : Moduls tool box 2.3


Please open Makefile in your project directory and modify these values.

CONFIG=Custom

CXXFLAGS= --param ipa-cp-max-recursive-depth = 20


Please refer to below link for more compiler options:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

 

Configuring depth of recursive function without compiler option:

You can increment a variable for each recursive call to determine the depth and can exit the recursion once it reaches depth of recursive call.

Example: 

int recursive(int i)
{
if(i==0  || count ==20)
return i;

count++;
recursive(i-1);

}


Thanks,
Krupashankar

View solution in original post

1 Reply
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @Sunny ,

Can you please share the details of your compiler and IDE version which you are using.

We have provided an example to configure depth of recursive function in compiler:
Compiler: arm-none-eabi-gcc
IDE : Moduls tool box 2.3


Please open Makefile in your project directory and modify these values.

CONFIG=Custom

CXXFLAGS= --param ipa-cp-max-recursive-depth = 20


Please refer to below link for more compiler options:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

 

Configuring depth of recursive function without compiler option:

You can increment a variable for each recursive call to determine the depth and can exit the recursion once it reaches depth of recursive call.

Example: 

int recursive(int i)
{
if(i==0  || count ==20)
return i;

count++;
recursive(i-1);

}


Thanks,
Krupashankar