This is the mail archive of the gcc-help@gcc.gnu.org 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: template compilation


"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


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