This is the mail archive of the gcc-bugs@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]

Re: BUG with template instantiation


Alexandre Oliva writes:
 > -fguiding-decls breaks iostreams.  Write correct ANSI/ISO C++, by
 > adding the following declarations:
 > 
 > template <class T> class Fred;
 > template <class T> friend ostream& operator<<(ostream&, const Fred<T>&);
 > template <class T> friend istream& operator>>(istream&,       Fred<T>&);
 > 
 > Then, add `<>' when you refer to these template functions in friend
 > declarations.
 > 

Thanks for the information. I did this in all my sources. But it seems
there is still a problem with stream... i.e. I get the following
output (I don't use guiding-decls)


>c++2 -I/usr/openwin/include -I/home/yoho2/lavoie/include -I../include -g -O2 -fno-implicit-templates -c tvqSort.C

>c++2 -o tvqSort tvqSort.o  -L/usr/openwin/lib -L/home/yoho2/lavoie/lib -L/home/yoho2/lavoie/lib   ../src/libmatrix.a  -L/usr/openwin/lib -L/home/yoho2/lavoie/lib -lXt -lX11 -lmfhdf -ldf -lXpm -lpng -ljpeg -lmpeg -ltiff -lz -ldpstk -ldps -ljbig -lMagick -lm -lc 
Undefined                       first referenced
 symbol                             in file
ostrstream type_info node           ../src/libmatrix.a(vector.o)
ostrstream type_info function       ../src/libmatrix.a(vector.o)
istream & operator>><double>(istream &, complex<double> &)../src/libmatrix.a(barray.o)
ld: fatal: Symbol referencing errors. No output written to tvqSort
collect2: ld returned 1 exit status


I really don't understand the first two. and I can't get rid of the
last one even though I added this line in the barray.cpp code

template istream& operator>><double>(istream& , complex<double>& ) ;



Is there a problem with template instantiation ? Or am I still missing
something about the new draft. The first two errors are really strange
because I don't have any operator>> or operator<< (or any functions
with stream in them) in the vector.cpp source.

thanks


Phil



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