Re: Is there stack associated when a executing an inline function?
- From: Paul Hsieh <websnarf@xxxxxxxxx>
- Date: Fri, 29 Feb 2008 11:03:56 -0800 (PST)
On Feb 28, 11:37 pm, Mahesh <mahesh1...@xxxxxxxxx> wrote:
I need to know if stack frames are generated in case of a
inline function execution or do they execute just like macros?
The implicit call stack retains all its behaviors as normal regardless
of function call decorations like "inline".
The only thing the standard can say about "inline" is that it prevents
an function's address be stored in a function pointer. For many
cases, this can already be established by the compiler, but this is
useful for compilers that don't. (Its essentially, a new keyword,
helpful for old compilers that will not be updated to the new
standard. Don't ask me; I had no hand in this.)
if they execute like macros, then what is the need for having
inline function?
macros just perform text substitutions, and cannot call themselves
recursively.
where would you use macros and where inlines?
You use macros to avoid call overhead and when text substitution is
sufficient. Macros also have certain compile-time capabilities that
you don't get from function calls: stringification with # x and text
concatenation via: x ## y.
--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
.
- Follow-Ups:
- Re: Is there stack associated when a executing an inline function?
- From: Keith Thompson
- Re: Is there stack associated when a executing an inline function?
- References:
- Prev by Date: Re: calculating length of an substring
- Next by Date: Re: calculating length of an substring
- Previous by thread: Re: Is there stack associated when a executing an inline function?
- Next by thread: Re: Is there stack associated when a executing an inline function?
- Index(es):
Relevant Pages
|