inlining or not inlining...

Jim bitcirkel at yahoo.com
Fri Feb 11 00:33:57 PST 2011


Jonathan M Davis Wrote:

> On Thursday 10 February 2011 22:35:34 Walter Bright wrote:
> > Stewart Gordon wrote:
> > > On 09/02/2011 12:14, spir wrote:
> > >> Hello,
> > >> 
> > >> Walter states that inline annotations are useless, since programmers
> > >> cannot generally know
> > >> which function /should/ be inlined --depending on a variety of
> > >> factors, inlining may in
> > >> fact be counter-productive.
> > > 
> > > <snip>
> > > 
> > > I hate not being able to force functions to be inline.  A consequence is
> > > that you can't fully interface certain APIs without an extra .lib over
> > > what would be needed in C(++).
> > 
> > You cannot force inlining in C(++) either. The inline keyword is only a
> > suggestion.
> 
> True. However, IIRC -O3 in gcc forces inlining, so in some cases you _can_ force 
> it (though that's obviously compiler-specific), but forcing inlining with -O3 
> does it for _everything_, so it's not exactly precision instrument.
> 
> Regardless, I would _hope_ that the compiler would be smart enough to make 
> intelligent choices about inlining. That's probably one of those areas that can 
> always be improved however.


I also think that this decision should be left to the compiler.

The inline keyword was deemed useful for the same reason that symbols had to be declared before their use (causing the C/C++ header hell) -- it's easier to implement such a compiler.



More information about the Digitalmars-d mailing list