This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
re: c++ template instanciation and dlls on win32
- From: Mathieu Lacage <Mathieu dot Lacage at sophia dot inria dot fr>
- To: Danny Smith <dannysmith at clear dot net dot nz>
- Cc: GCC-help at gcc dot gnu dot org
- Date: Sun, 01 Jul 2007 15:39:59 +0200
- Subject: re: c++ template instanciation and dlls on win32
- References: <000001c7bbca$e9903b00$716d65da@THOMAS>
On Sun, 2007-07-01 at 22:30 +1200, Danny Smith wrote:
> > Here is my sample code:
> > http://www-sop.inria.fr/dream/personnel/Mathieu.Lacage/tmp.tar.gz
>
>
> This is what I would do:
>
> Exolicitly, force instantiation of your template instance in dll:
ok.
>
> diff -c3p tmp/test.cc tmp0/test.cc
> *** tmp/test.cc Sat Jun 30 21:30:22 2007
> --- tmp0/test.cc Sun Jul 1 15:49:20 2007
> ***************
> *** 1,5 ****
> --- 1,8 ----
> #include "test.h"
>
> + // instantiate
> + template class Test <0>;
> +
> void Function (void)
> {
> Test<0>::Exec ();
>
>
>
> Explictly mark the reference to your imported instantation as imported.
This begs the question as to whether it is possible to automate the
import: can I tell gcc that it should not implicitely generate any
template instanciation and that it should import it instead ? I cannot
see myself having to explicitely import every possible instanciated
template so, I am trying to find a workaround.
I tried to make sure that gcc does not implicitely generate any template
instanciation but -fno-implicit-templates did not seem to achieve
anything: objdump still shows the method body in the object files. Is
there something extra I need to do ? And if I can make the no generation
option work, is there a way to tell gcc to import every non-generated
instanciation ?
sorry if the answer is obvious but I am a bit lost here.
Mathieu