Re: Is there stack associated when a executing an inline function?



Mahesh wrote:
Hi,
I need to know if stack frames are generated in case of a
inline function execution or
do they execute just like macros?

A stack <frame> will not be generated but any local
storage that the inline function uses will be added to
the local storage of the calling function.

void inline fn(int n)
{
char[1024*64];
// ...
}

That will add 64K to the local storage of all functions that use
the inline function, IF the compiler decides to inline the
function. Note that a compiler can decide not to inline anything.
(For instance it can decide to not inline when the debug
option is ON)


if they execute like macros, then what is the need for having
inline function?

Because parameter passing is safer, since all normal checks
are done. Besides, you are sure that the parameters are
evaluated once only.

where would you use macros and where inlines?


Macros can be handy in places where precisely you do NOT want
the checks done with inline functions, and you want a textual
substitution.

Thanks
Mahesh


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
.



Relevant Pages