Re: inline and macro

From: Lucas Galfaso (lgalfaso_at_NO_CAPSfd.com.ar)
Date: 02/22/04


Date: Sun, 22 Feb 2004 15:30:37 -0300

Hi, inline fuctions (if inlined) and macros shoud be equally fast (actually,
produce the same code.)
I prefer inline functions to macros, because macros polute the global
namespace (at least, until #region is aproved)
The compiler may or may not inline a function declared inline. ie if you
have a recursive inline function, it will not be inlined.

Be aware that some (very odd) cases that inline functions are slower that
not inlined ones exists.

Lucas/

"Nelson" <doomer999@hotmail.com> wrote in message
news:e3xXGIV%23DHA.1456@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> Are inline functions or macros faster? I want to know because I'm writing
a
> fast graphics library and I found that the overhead of calling functions
> reduces speed significantly. So the only solutions I can think of are
inline
> functions and macros.
>
> Also, I heard from someone that the compiler may not insert the code in
the
> inline function into the function caller. Is that true? In what situation
> would that happen?
>
> Thanks,
> Nelson
>
>



Relevant Pages

  • Re: Alternatives to #define?
    ... >> But macros can be difficult to follow too. ... >> large parts of the code by switching a compiler flag. ... > inline void doStuff() ...
    (comp.lang.cpp)
  • Re: Alternatives to #define?
    ... > but for example logging macros and testing macros can be difficult to read ... But I do like how the compiler has an opportunity to remove ... inline void doStuff() ...
    (comp.lang.cpp)
  • Re: [PATCH 19/24] Unionfs: Helper macros/inlines
    ... This patch contains many macros and inline functions used thoughout Unionfs. ... Please prefer to use inlined C fucntions. ...
    (Linux-Kernel)
  • Re: #pragma inside #define
    ... >compiler to inline functions when possible. ... >strlen code is much slower than the function call, ...
    (microsoft.public.vc.language)
  • Re: inline functions
    ... A function declared with the function specifier "inline". ... > When should we declare a particular function as inline? ... i.e. the compiler is free to do nothing. ... Then why not use macros? ...
    (comp.lang.c)