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



In article <fq8jmu$j4j$1@xxxxxxxxxxxxxxxxxxxxxxxxx>,
santosh <santosh.k83@xxxxxxxxx> wrote:

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

One major advantage (and sometimes a major disadvantage) is the type
checking you get with inline functions.

You generally don't lose type checking with macros, because the
expansion gets type checked in the usual way. If getc is a macro and
you call it with something that isn't a FILE *, you'll probably
get a bunch of fatal, if unclear, errors.

The more compelling reason for inline functions is that you can't
use arbitrary constructs in macros that are used in expressions.
C's macros are just powerful enough to let you write getc and putc,
but anything that needs declarations or a loop can't be done.

-- Richard
--
:wq
.



Relevant Pages

  • Re: CERT C Secure Coding Standard - last call for reviewers
    ... The claim that 'macros are dangerous' can, to a certain extent, be ... suggests that inline functions can eliminate this problem. ... the terms of reference of SECCODE, the suggestion to use inline functions ... The example where the interaction of two macros and a file scope object ...
    (comp.lang.c)
  • Re: Cleaning up FILE in stdio..
    ... Macros and __inline functions mean that a significant proportion of ... software compiled on FreeBSD has the existing definition of FILE ... glibc handles this just fine) ... Remove the macros and inlines that poke around inside FILE ...
    (freebsd-arch)
  • Re: C++ as a better C
    ... the overhead of calling the function may be high ... macros have no concept of type safety and can have some nasty ... Inline functions offer many of the benefits of macros, ... int main ...
    (comp.lang.cpp)
  • Re: [PATCH 5/6] i386 virtualization - Make generic set wrprotect a macro
    ... and fixes the build for architectures which include pgtable.h ... >This against the kernel coding style. ... "functions" here are purely macros, ... inline functions for include/asm-i386/pgtable-level.h. ...
    (Linux-Kernel)
  • Re: Extreme Efficiency for Odd/Even
    ... C++-ers have used against function macros for years now apply to C. ... would write those as inline functions and only switch to macros after ... Pay close attention to "I would..."; it has a very different meaning ...
    (comp.lang.c)