Suppose we have below code:
inline void DoSome()
{
cout << "do some" << endl;
}
int main()
{
void (*pDoSome)() = DoSome;
DoSome(); // one
pDoSome(); // two
}
For above code we have three possible scenarios:
Now I want know which of the above scenarios is true?
inline is a hint to the compiler, but it is not an obligation. It is up to the compiler to decide if a function declared as inline will actually be inlined and thus any of the two calls may or may not be inlined.
All scenarios are possible, because the compiler may optimise as it wants. The only option to see what happened is to look in the assembler output.
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