From: Robert M D. <bob...@us...> - 2003-01-15 20:03:11
|
Greg, Thanks for the info. The URL is especially useful. ****************************************************************************** Bob Dorazio United States Geological Survey 7920 NW 71 Street Gainesville, Florida 32653 Phone: (352) 378-8181 x373 Fax: (352) 378-4956 Email: bdo...@us... Internet: www.fcsc.usgs.gov Greg Chicares <chicares@mindspr To: Robert M Dorazio <bob...@us...>, ing.com> min...@li... cc: 01/15/2003 01:28 Subject: Re: [Mingw-users] linkage failure when template decls and defs are in PM separate files Please respond to mingw-users Robert M Dorazio wrote: > > I'd like to keep template declarations and template definitions in separate > files; however, I encounter the following error when trying to compile and > link a simple example (taken from p. 351, Stroustrup 2000 The C++ > Programming Language). [...] > export template<class T_numtype> void out(const T_numtype& t) { ^^^^^^ gcc doesn't support 'export', and neither do most compilers. AFAIK only comeau does. This URL discusses gcc template options: http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html Don't try the -frepo thing; it doesn't work with mingw, because it requires collect2, which mingw does not supply. Before trying any -f... options, look them up in the manual for the version of gcc you're using, because some of them may have been removed or deprecated. You can do explicit instantiation, declaring every template in a header and implementing it in a .cpp file. I've done it but it didn't seem to have any real effect on compile times--so conceivably I overlooked something. But since that experiment I've just put template implementations in headers. |