Inline limitation?
Joe Buck
jbuck@synopsys.com
Thu Aug 20 00:51:00 GMT 1998
> There is such a warning, -Winline. I am not a compiler guru so I don't
> know how difficult it is to do inline regardless of the order of
> definition and use of functions. I know that our Sun C++ Version 4.2
> does inlining regardless of the order of definition.
No, Sun's compiler is not omniscient and can't always inline regardless of
the order of definition (though it evidently can inline in a couple of
cases where g++ cannot).
> This is very helpful in C++ because there are a lot of short,
> inlinable functions but the order of #includes forbids a
> define-before-use ordering. So egcs is losing a big opportunity
> to optimize here.
I doubt it. You may be forming the mistaken impression that g++ can
never inline a function that appears after its call, however in at least
some cases it can (e.g for functions defined in the class declaration, to
a limited degree).
If you are worried that you are losing optimization, turn on -Winline,
which will tell you which functions cannot be inlined. You could then try
reordering only the most important calls.
More information about the Gcc
mailing list