Folks,
I was reading "Thinking in C++" (Chap - Inline functions), where I encountered this statement.
"The compiler also cannot perform inlining if the address of the function is taken implicitly or explicitly".
What does that mean by "taking address of function implicitly or explicitly" ?
Why it is not possible to inline in this case ?
Thanks.
Taking the address of a function means assigning it to a function pointer. This can happen explicitly, as in the linked examples. I am not sure what the author means by "implicitly" - maybe things like passing a function as a parameter to another function.
If the address of the function is taken, it must have an address in the first place. Since inlining means basically substituting calls to the function with a copy of its body, after such a transformation the function no more exists, thus has no address - only n distinct copies of identical code in places where there used to be calls to that function. Thus if a function's address is used in any way, it can't be inlined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With