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



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/
.



Relevant Pages

  • Re: Is there stack associated when a executing an inline function?
    ... inline function execution or do they execute just like macros? ... Macros are simply text ... Inline is just a hint to the compiler, which it is free to ignore. ...
    (comp.lang.c)
  • Re: How to get name of calling function
    ... > function to also be able to display the function that called it. ... One involved using C macros. ... > said that the code for an inline function gets replaced wherever the ... _preprocessing_ time. ...
    (comp.lang.cpp)
  • Re: Fast and Safe C Strings: User friendly C macros to Declare and use C Strings.
    ... The macros are not compatible with PL/I or BPX1*. ... For some years, using Borland compilers, I managed to get the 2 byte length field just in front of the string. ...
    (bit.listserv.ibm-main)
  • Re: files "." and ".." from readdir()
    ... What is your justification for others to use an inline function over a ... | There is no alloca in the macro above. ... suggested to use inline functions instead of macros. ... not called from in the same compiled unit. ...
    (comp.unix.programmer)
  • Re: silly: "spel" instead of "macro"
    ... > I don't write Lisp compilers, so I don't know the intricate details ... You don't need to write Lisp ... I know what Lisp macros are capable of. ... artifact is an annotated syntax tree - a data structure recursively ...
    (comp.lang.lisp)