This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: using templates in shared library


> and link it to the library. Obviously, since the library already
> exists, it is possible to see that 'vector<int>' is present in the
> library. I therefore want the 'main.o' or 'a.out' NOT to include the
> 'vector<int>' instance. It will only make it bigger if the symbols
> were included, since the library is going to override the weak symbols
> anyway.

This is not how shared-library versioning works. A newer version of
the library still needs to export the same set of global symbols to be
binary compatible.

However, if an function implementation slightly changes, people do
expect that they don't need to recompile all applications. With your
proposal implemented, they might need to: the slight change could
cause an implicit template instantiation to go away, and programs
relying on the implicit instatiation to be in the library would break.

If you want the linker to consider this instantiation intentional, and
as a public interface of the library, you need to instantiate
explicitely.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]