compiling templates with g++

Amit Mehrotra amehrotr@vlsisrv2.csl.uiuc.edu
Thu Dec 23 12:50:00 GMT 1999


But if I use this code in multiple source files, all of those which include
the header file with the implementation, the linker complains about
duplicate definitions!

Amit

> Put the definitions of your template functions in your header file.
> 
> If this causes problems, run 'info gcc' and then type 'gTemplate Instantiation'
>   (info will tab-complete, like bash and tcsh).
> 
> gcc does not yet support having a definition of a templated function in a
>   compilation unit separate from where it is used. 

> ANSI C++ requires a definition of a templated function to be declared
>   'export' for it to be availible to other compiliation units, but, as I
>   said before, gcc doesn't support that yet.


More information about the Gcc-help mailing list