help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: template instantiation g++ 4.0x


From: Paul Pluzhnikov
Subject: Re: template instantiation g++ 4.0x
Date: Mon, 20 Mar 2006 20:43:58 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Tom Hilinski <tom@nowhere.net> writes:

> I'm unable to get template code that builds with g++ 3.4.x to link
> successfully in g++ 4.0.x

I am suprised your code builds with gcc-3.x (but it does build with
my gcc-3.3.3). I was also able to reproduce your build failure
using gcc-4.1-20051022 snapshot.

> I'd appreciate any suggestions.

What you are doing is non-portable: when the instantion requests below
are seen by g++, it has not seen the body of ATemplate<T>::GetValue()
yet, and therefore can't actually instantiate anything.

> template class ATemplate<int>;
> template class ATemplate<float>;

Here is a fix:

  $ cat ATemplate.cpp
  #include "ATemplate.h"
  template <class T> T ATemplate<T>::GetValue () const { return n; }
  template class ATemplate<int>;
  template class ATemplate<float>;

Your ATemplateInst.h serves no apparent purpose anyway.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]