egcs-19990629 complex instation problem
Mumit Khan
khan@xraylith.wisc.EDU
Sat Jul 31 23:33:00 GMT 1999
jarausch@igpm.rwth-aachen.de writes:
> Hi,
>
> Trying to explicitly instantiate (snaphot 19990629) doesn't work in the
> following case. This did work in egcs-1.1.2
>
> #include <iostream>
> #include <complex>
> template istream& operator>>(istream& , complex<double>&);
>
> gives
>
> TI.C: In instantiation of `operator >><double>(istream &, complex<double> &)'
> :
> TI.C:3: instantiated from here
> TI.C:3: explicit instantiation of `operator >><double>(istream &, complex<dou
> ble> &)' but no definition available
>
> The code is in
>
> /usr/local/include/g++-2/std/complext.cc
>
> and
> /usr/local/include/g++-2/complex
>
> includes
> /usr/local/include/g++-2/std/complext.h
>
>
> Thanks for a hint
Here's a hint (and this is a general troubleshooting tool with GCC):
$ gcc -save-temps -c T1.C
Now look inside T1.ii and see if you find the *definition* of
`template <class T> istream& operator >> (istream&, complex<T>&);'
Surprise, it's not there; <std/complext.cc> is not included by any
of the files you're including, and that's where the definition is,
and is used when building the libstdc++ runtime library.
Hack:
#include <iostream>
#include <complex>
#include <std/complext.cc> // make definitions available
using namespace std;
template istream& operator>>(istream& , complex<double>&);
Regards,
Mumit
More information about the Gcc-bugs
mailing list