Re: One-definition rule for inline functions

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

On 8 March 2012 01:44, Timothy Madden wrote:
> What does g++ do with this template ?
> Does it really compile any templates in each and every .cc file that they
> are used in ?

Yes, as it says at the same page
( templates also
have vague linkage. If you follow the "Where's the template?" link
there's a whole page on the topic: (ignore
the paragraph about "a future version of G++")

You can use an explicit instantiation declaration (i.e. "extern
template") to suppress the implicit instantiation in every file that
uses the template:

extern template void draw_unit_vector<int>();

If you do that then you must ensure that an explicit instantiation
definition appears in exactly one object file:

template void draw_unit_vector<int>();

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

Add to Google