I'm a newbie programmer. There are these line in our text book, sumitha arora class 12 ix edition:
The inlining does not work for the following situations:
For functions that return values and are having a loop or switch or goto.
For functions not returning values, if a return statement exists.
If 1 and 2 are true then how are inline functions possible to create?
P.S. the lines are exactly the same from the book no alterations
I don't know what compiler is referred in the book. In general it will depend on the actual compiler, what can be inlined or when a function body will be generated.
The statements doesn't exclude each other as you might assume. The general condition to inhihbit inline is a branch in the function except a simple if statement. The branches in (1) are the loops and the goto. The branch in (2) is the jump to the end of the function on return;
Edit:
It is highly dependent on the compiler. Nested if might work. But switch statements differs, as they are often implemented with a jump table instead of several if statements. The jump table includes location similar to the goto labels. That might be more difficult for the actual compiler. Therefore it might be sensible to make a distinction.
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