Hello
I'm trying to compile Sascha Volkenandt's streamdev plugin and I have the following error:
g++ -W -Woverloaded-virtual -O2 -c -D_GNU_SOURCE -DHAVE_AUTOPID -I../../../include -I../../../../DVB/include -I. -o streamdev-client.o streamdev-client.c ./tools/list.h:93: error: declaration of 'operator+=' as non-function ./tools/list.h:93: error: expected ';' before '<' token ./tools/list.h:94: error: declaration of 'operator+=' as non-function ./tools/list.h:94: error: expected ';' before '<' token ./tools/list.h:96: error: declaration of 'operator+' as non-function ./tools/list.h:96: error: expected ';' before '<' token
Here's one of the problematic line:
friend cTBList<T> &operator+= <> (cTBList<T> &list1, const cTBList<T> &list2);
This kind of declaration involving templates and operator overload goes way over my puny C++ knowledge.
Can somebody help me in fixing this problem ?
Thanks
Dominique Dumont wrote:
I'm trying to compile Sascha Volkenandt's streamdev plugin and I have the following error:
g++ -W -Woverloaded-virtual -O2 -c -D_GNU_SOURCE -DHAVE_AUTOPID -I../../../include -I../../../../DVB/include -I. -o streamdev-client.o streamdev-client.c ./tools/list.h:93: error: declaration of 'operator+=' as non-function ./tools/list.h:93: error: expected ';' before '<' token
Here's one of the problematic line:
friend cTBList<T> &operator+= <> (cTBList<T> &list1, const cTBList<T> &list2);
This is not latest CVS streamdev, it must be some older version.
Anyway, this is a GCC-4 compatibility issue. GCC4 follows the ISO C++ standard very closely, while GCC3 allowed some non-standard things to pass through.
In this case: A friend declaration no longer is a forward declaration, so these operators have to be forward-declared.
The following is from a patch for mplayercluster, that uses a variant of clist:
// ANSI/ISO C++ and GCC4 require template friend functions to be forward-declared... template <class T> class cTBList; template <class T> inline cTBList<T> &operator+= (cTBList<T> &list1, const cTBList<T> &list2); template <class T> inline cTBList<T> &operator+= (cTBList<T> &list, const T &element); template <class T> inline cTBList<T> operator+ (const cTBList<T> &list1, const cTBList<T> &list2); template <class T> inline cTBList<T> operator+ (const T &element, const cTBList<T> &list); template <class T> inline cTBList<T> operator+ (const cTBList<T> &list, const T &element);
Put it right before the template <class T> class cTBList declaration. It might need some modifications, depends on your clist.h.
Cheers,
Udo
Udo Richter udo_richter@gmx.de writes:
This is not latest CVS streamdev, it must be some older version.
Well, I'm using the latest unstable tarball from Sascha's site.
Anyway, this is a GCC-4 compatibility issue. GCC4 follows the ISO C++ standard very closely, while GCC3 allowed some non-standard things to pass through.
So far so good, I understand.
In this case: A friend declaration no longer is a forward declaration, so these operators have to be forward-declared.
:-0 ... [scratching my head] ... Let's try cvs, it will be way faster :o)
I've finally found the cvs instructions from the german wiki (fortunately, cvs is also spelled 'cvs' in german ;-) )
I've managed to compile streamdev (with Deti's patch posted last week) on my Debian sid box.
Thanks for your help.
Cheers