+ 8

Is it possible to have a recursive inline function ?

23rd Aug 2019, 8:23 AM
Bhavik Bhuva
Bhavik Bhuva - avatar
7 odpowiedzi
+ 5
Inline is just a request to the compiler to treat the call to a function like a macro and substitute it rather than treating it as a function and making a call. This request may or may not be considered by a compiler where in the second case it treats it as a normal function rather than inline. So even though you do try to make a recursive function inline the compiler will ignore it and consider it as a normal function and work in the normal fashion to execute it. P.S Doing this is definitely not a good coding practice.
24th Aug 2019, 9:46 AM
Harshita Verma
Harshita Verma - avatar
23rd Aug 2019, 8:27 AM
Uchiha Itachi
Uchiha Itachi - avatar
+ 4
I would say that compilers would probably never inline a recursive function.
24th Aug 2019, 1:18 PM
Sonic
Sonic - avatar
+ 2
Yaa Right
24th Aug 2019, 9:50 AM
Prad_ip
Prad_ip - avatar
+ 2
Although you can call an inline function from within itself, the compiler will not generate inline code since the compiler cannot determine the depth of recursion at compile time.
31st Aug 2019, 3:34 AM
Bhagirath Dudharejiya
Bhagirath Dudharejiya - avatar
+ 1
Yessssss it's possible
6th Oct 2019, 12:26 PM
govind
govind - avatar