This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RE: Error compiling templates
- To: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Subject: RE: Error compiling templates
- From: "CPoblete" <poblete at lim dot com>
- Date: Mon, 30 Aug 1999 10:28:56 -0500
- Cc: <egcs-bugs at egcs dot cygnus dot com>, "Cpoblete at Acm dot Org" <cpoblete at acm dot org>
> Thanks for your bug report. Your implementations are not correct. In
> C++, you must define a specialization before you use it for the first
> time; you didn't.
>
> In Truck2.h, you have the field
>
> Auto<Truck, Nissan> _nissan;
>
> which leads to the instantiation of the class Auto<Truck,
> Nissan>. Later, you define a specialization. The compiler now
> complains that you cannot declare a specialization after the template
> was already instantiated. When you fix this, the error goes away.
>
I am aware of this logic. However, I am trying to port our server, which
contains 500,000+ lines of c++ code (100+ template classes), from Sun to
Linux.
Our code has been compiling with NO problem in Sun and HP as well as gcc
2.7.x and the old egcs. It also compiles in Visual C++!!! Besides the
author of our code has 5+ years more experience than I am, and cares less if
we cannot port them to Linux. egcs compiler fix is my only hope.
Further, when Auto class is instantiated before specialization the ff.
compiles:
template <class Truck, class Nissan>
Auto<Truck, Nissan>::foo() {}
But this one does not:
Auto<Truck, Nissan>::foo() {}
Thanks.