Re: Weak symbols and inline

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

 



On Thu, 27 Feb 2014, Paul Smith wrote:

Hi all; I'm using C++ built with GCC 4.8.2 / binutils 2.23.2 on a
GNU/Linux system.

When I create a global function marked "inline" I see, using nm, that a
weak symbol ("W") is added to the object file for that function.

For link-order reasons, I would prefer that the inlined function not
generate any (external) symbol; in particular I do NOT want this object
to be pulled in from a static library just because it happens to appear
first in the archive order.  I have another object in the archive which
declares a global symbol ("T" in nm) and I want that one linked instead.


I don't see an __attribute__ setting that specifically controls this (I
can force a symbol to be weak, but that's not what I want).

I did discover that if I use __attribute__((always_inline)) then it does
what I want and doesn't add a weak symbol into the object.

Is that an approved usage of this attribute?  It doesn't appear to be
explicitly documented so I'm concerned that it's just a side-effect that
can't be counted on going forward.

Is there a better solution?

Did you try "static" or an anonymous namespace?

--
Marc Glisse




[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