Re: inline functions not inlined
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 07 Mar 2006 05:29:02 GMT
Ian Collins <ian-news@xxxxxxxxxxx> writes:
Keith Thompson wrote:
Bilgehan.Balban@xxxxxxxxx writes:Maybe it's an added complexity like 'register' which the language
If I define an inline function in one .c file, and use it from another,C99 6.7.4p5:
after compiling and linking the two, it seems the function is not
inlined but rather called as a regular function. I would expect to see
it inlined during linkage of the two object files. Does inlining only
occur if the inline function is defined within the same file that it is
called?
A function declared with an inline function specifier is an
_inline function_. The function specifier may appear more than
once; the behavior is the same as if it appeared only once. Making
a function an inline function suggests that calls to the function
be as fast as possible. The extent to which such suggestions are
effective is implementation-defined.
So an implementation isn't required to do anything special with an
inline function (it's like "register" in that sense).
would be better off without. A hangover from older compilers with
poor optimisation.
Let the optimiser to the work.
I suspect that modern compilers aren't as good at automatically
inlining functions as they are at assigning variables to registers,
and that user-controlled inlining still makes sense. (I have no hard
data to back that up.)
Providing inline could also tend to discourage the somewhat dangerous
use of macros as "faster" functions.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: inline functions not inlined
- From: Ian Collins
- Re: inline functions not inlined
- References:
- inline functions not inlined
- From: Bilgehan . Balban
- Re: inline functions not inlined
- From: Keith Thompson
- Re: inline functions not inlined
- From: Ian Collins
- inline functions not inlined
- Prev by Date: Re: Optional elements in a structure declaration? ( URGENT)
- Next by Date: Re: How does this (program) array work?
- Previous by thread: Re: inline functions not inlined
- Next by thread: Re: inline functions not inlined
- Index(es):
Relevant Pages
|