Re: On inlining of functions across 2 or more object files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rohit Garg wrote:

> My question is that the functions which are called from file1.o are
> inlined for speed. And they reside in file2.o. Now, the gcc docs say
> inline functions are as fast as a macro. My question is, does the
> inliine expansion work even when code is distributed across different
> object files?

No, the definition of the inline function must be in the same
compilation unit as its call sites in order for it to be inlined, which
means you need to put it in a header or otherwise arrange for it to be
seen in every CU.

> Further, this small ambiguity should be preferably cleared up in the
> web based docs itself. If maintainers allow,  I would like to
> contribute this.

I don't see what the ambiguity is.  Macros have the same property, that
they are required to be defined in a header that's included in every
source file that uses them.  What you're doing currently would fail to
compile if using macros, so it's not really meaningful to try to compare
the two.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux