This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]