0

Can anybody tell that when Inline won't work though we have declared function as inline. i.e code replacement won't take place .

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

its totally up to the compiler whether it honors the inline keyword or not, and there is no way to force the compiler to do it one way or the other, except maybe make the inline code a macro.

0

*sniff* - smells like a homework question to me.

Here's one answer (for now) #define inline /* ha ha, no more in-lining today Jeeves */ I'll leave method number 2 for a day or so to add a sense of mystery and wonder (or merely just wait for someone else to post it).

0

inlining does not take place

in the presence (or absence) of some compiler switches / #pragma directives.
eg. presence of -fno-inline or -finline-limit=small_number / absence of -O in g++

for functions that are called using pointers obtained at runtime.
eg. C callbacks (the comparison function for qsort), C++ virtual functions called polymorphically

if the level of nested or recursive calls to inline functions goes above a certain implementation defined limit

0

>>inlining does not take place
And at the discrection of the compiler at all times. The compiler can decide to ignore inlining at all times if it wants to. inline is only a suggestion to the compiler, not a requirement that it has to honor.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.