This is the mail archive of the
mailing list for the GCC project.
Re: templates undefined refrence problem
- From: "Arun Saini , Gurgaon" <arun at ggn dot hcltech dot com>
- To: Jeff Dever <jsdever at sympatico dot ca>
- Cc: mike stump <mrs at windriver dot com>, gcc at gcc dot gnu dot org
- Date: Tue, 19 Feb 2002 21:43:56 +0530
- Subject: Re: templates undefined refrence problem
| Its pretty ugly having implementation in my header
| files, and I'm not creating nice intermediate .o files anymore, but at
| least it compiles and runs. I didn't realize that was industry practice
It is ugly, I agree but it is a limitation of the compiler and not the
language. It is an industry practice because most compilers still do not
support the "export" keyword.
| I'm surprised that this was not a FAQ answer. This issue does not appear
| on the c++ faq as far as I could find with Google.
It is part of the file bugs.html distributed with gcc 3.x. I qoute
"Most C++ compilers (G++ included) do not yet implement export, which is
necessary for separate compilation of template declarations and definitions.
Without export, a template definition must be in scope to be used. The
obvious workaround is simply to place all definitions in the header itself.
Alternatively, the compilation unit containing template definitions may be
included from the header."
| mike stump wrote:
| > Get rid of all .cc files, except main. Welcome to C++.
This is not C++, just a workaround.