This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: template compilation
- From: Oscar Fuentes <ofv at wanadoo dot es>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 10 May 2003 22:51:35 +0200
- Subject: Re: template compilation
- Cancel-lock: sha1:amF8ZsAEda0mNofSyvQk8fIseqg=
- References: <Sea2-DAV65kPgxXhmjd00003480@hotmail.com>
"federico" <federicolcc@hotmail.com> writes:
> I have some problems linking these files.
>
> The only way it woks is including the server.cpp
> file
> in main.cpp. ¿Is there another way out, that is
> including in
> main.cpp only the server header file?
> In the C++ programming languaje I learned I had to
> include "export" before the definition of the tamplates function so that
> they could be recongnized from other translation units. But it doesn't work with
> g++.
> ¿What should I do?
"export" is not supported by most existing compilers, g++
included. All your template code must be visible on the instantiation
point. This is achieved by either
1. Putting all template code on header files and #include them on the
.cpp file where you want to use that templates.
2. Putting all template definitions (the sort of thing you have on
your .cpp file) on a file and #include that file at the end of the
header that declares the templates.
On some contexts, you can explicitly instantiate the templates you
need, but this is not a good thing on the general case.
--
Oscar