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

Re: Undefined reference to '...'

On Sep  3, 1997, at 13:47, Jason Gunthorpe wrote:
 > 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..

That's a shame... Hopefully, egcs will do a better job.

 > 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.

Well, I've been working on a big project (~200.000 lines C++ code) on
Irix (Silicon Graphics), and it doesn't recursively instantiate
templates either. While I agree it is cumbersome to manually
instantiate EVERY template generated by your example, I think it is
not such a big deal: you do it once (for each used template) and you
are done. What's better, you know your code (executable or library)
will only contain code that you are actually using, not a superset
computed by the compiler to make sure things will work.

 > 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.

This is an interesting workaround; alas, it is non-portable.

 > Jason

Gonzalo A. Diethelm G.

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: