This is the mail archive of the
mailing list for the GCC project.
Re: Template ctor/dtor undefined at link
- To: Robert Boehne <rboehne at ricardo-us dot com>
- Subject: Re: Template ctor/dtor undefined at link
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 02 Oct 2001 20:00:24 +0100
- CC: gcc at gcc dot gnu dot org
- Organization: Codesourcery LLC
- References: <3BB8C245.DBB5EE78@ricardo-us.com>
Robert Boehne wrote:
> I can't determine whether this particular problem is a compiler
> problem or a (most likely) programmer error. I have a template
> class with a constructor that takes a pointer to the template
> argument, gcc 3.0.1 x86 Linux and Aix 4.3 as well as egcs-2.91.66
> all have unresloved symbols at link time, some other compilers don't.
This is user error. Until 'export' is implemented, the bodies of
template functions must be visible at the point of instantiation (roughly
speaking). Or you could explicitly instantiate them for all the required
types where they are visible.
They need to be as visible as inline functions are. Don't worry about
multiple instantiations of the specialization causing linker problems --
it knows to ignore all but one.
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
firstname.lastname@example.org : http://www.cs.bris.ac.uk/~nathan/ : email@example.com