Why wouldnt this work?

This:

"The compiler may not always be able to insert the code for a function inline (such as with recursive functions or functions for which you have obtained an address), but generally, it will work."

For a function inline why wont it work for a recursive function or a function for which you have obtained an address?

Why cant the compiler still insert the inline? Can someone please explain.
For a function inline why wont it work for a recursive function

This one should be obvious - because it would lead to infinitely large code, as the compiler would repeat the function code inside the function code, inside the function code, over and over again.

The number of times a recursive function calls itself will depend on runtime variables - so the compiler can't know how many times to inline the code. And you certainly don't want it to do it an infinite number of times!
Last edited on
Oooh good point. I forgot that it depends on runtime variables. Thanks but can you please explain the second reason? Thanks
Again, because the address of a function is going to be runtime information, rather than something the compiler can know about upfront.
I feel so dumb now lol.

Anyways thanks!
Last edited on
Topic archived. No new replies allowed.