[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gcc-3.4.0 && std::valarray compile problems?:REPOST
From: |
Bernd Strieder |
Subject: |
Re: gcc-3.4.0 && std::valarray compile problems?:REPOST |
Date: |
Tue, 27 Apr 2004 19:36:05 +0200 |
User-agent: |
KNode/0.7.2 |
Hi,
STH wrote:
> This didn't go through the last time. ????
It did. Either newsreader or newsserver or newsuser broken ;-)
>
> I've been haveing trouble compileing the code found at this URL:
>
> http://www.research.att.com/~bs/matrix.c
This has to do with the much improved parser in gcc-3.4.0, which is much
more unforgiving to sloppy code. See the changes document at
gcc.gnu.org.
Add
template<class T> class Slice_iter;
template <class T>
bool operator==(const Slice_iter<T>& p, const Slice_iter<T>& q);
template <class T>
bool operator!=(const Slice_iter<T>& p, const Slice_iter<T>& q);
template <class T>
bool operator< (const Slice_iter<T>& p, const Slice_iter<T>& q);
before definition of class template Slice_iter, and
template<class T> class Cslice_iter;
template<class T>
bool operator==(const Cslice_iter<T>& p, const Cslice_iter<T>& q);
template<class T>
bool operator!=(const Cslice_iter<T>& p, const Cslice_iter<T>& q);
template<class T>
bool operator< (const Cslice_iter<T>& p, const Cslice_iter<T>& q);
before definition of class template Cslice_iter.
This leaves some probably harmless warnings.
The compiler expects to know the functions you tell it to be friends
before. If the functions have to know the class template they are
supposed to become friends with afterwards, then you have to declare
the class template before the functions. This is how C++ is supposed to
be.
>
> g++ matrix.cc
> matrix.cc: In instantiation of `Slice_iter<double>':
> matrix.cc:145: instantiated from here
> matrix.cc:36: error: template-id `operator==<>' for `bool
> operator==(const Slice_iter<double>&, const Slice_iter<double>&)' does
> not match any template declaration
The compiler does not know any matching operator==. The only place to
introduce it would have been before the class template. The same with
the next 5 errors, the other errors follow directly from the first 6.
Bernd Strieder