Re: Undefined reference to '...'
> On 03-Sep-97 Gonzalo A. Diethelm wrote:
> >The only official way sanctioned by the upcoming C++ ANSI/ISO standard
> >to instantiate templates is to explicitly mention the types you want
> >to use for instantiation. All of the repository techniques that exist,
> >some better, some worse, are not standard and that's one reason why
> >you do this differently on each platform.
> >If you ask me, explicit instantiation is the correct way, because it
> >gives you the control on where, when and how many times (hopefully
> >just once!) you instantiate something.
I missed the original post on this but..
I would like to point out that GCC doesn't explicitly instantiate too well
when running with -fno-implicit-templates, which is what I would like to
use in my sources..
The trouble is that it doesn't recursively instantiate, ie if you use STL
and put the line
template class vector<int>;
In some .cc file to force instantiation then you will not get
instantiation of the helper functions the template uses, things like max,
min, etc. Furthermore the way gcc 2.7 has been choosing template instances
sometimes results in it generating a large number of pointless
instantiations when using stl. If you were to use explicit instantiation
with gcc 2.7 and STL you would end up with about 20 lines per stl class
you instantiate to catch all the functions and so on required.
I hope egcs fixes alot of problems like this :<
BTW, as I mentioned before if you use -fno-implicit-templates then add all
your instantiations as above into a single file that is not compiled
-fno-implicit-templates it will properly recurse, but I do not think that
is portable across all gcc platforms.
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
Trouble? e-mail to firstname.lastname@example.org .