public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* template(s) declaration with GCC3.2-7
@ 2003-04-22 16:34 Rade Trimceski
  2003-04-22 16:48 ` John Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: Rade Trimceski @ 2003-04-22 16:34 UTC (permalink / raw)
  To: gcc-help

Hey guys (and girls if there are any) :)

I'm trying to compile code that was written a while ago, and compiled
just fine with gcc 2.96. GCC 3.2-7 doesn't like it at all. Here's the
code as I extracted it from the header file:

[rtrimces@Vaio tests]#cat template_test.cpp
#include <list>

template <class _Tp>
class LsList : public list<_Tp> {
public:
	typedef list<_Tp> baseList;
	LsList() : baseList() {}
	LsList(const _Tp& x) : baseList(1, x) {}
	void eraseAll() {
		baseList::erase(begin(), end());
	}
	LsList<_Tp>& operator= (const LsList<_Tp> & x) {
		return (LsList<_Tp> &)baseList::operator= (x);
	}
};

When trying to compile I get the following errors:
[rtrimces@Vaio tests]# g++ -o template.o template_test.cpp
template_test.cpp:4: parse error before `<' token
template_test.cpp:7: ISO C++ forbids declaration of `LsList' with no
type
template_test.cpp: In function `int LsList()':
template_test.cpp:7: `int LsList()' redeclared as different kind of
symbol
template_test.cpp:4: previous declaration of `template<class _Tp> class
LsList'
template_test.cpp:4: previous non-function declaration `template<class
_Tp>
   class LsList'
template_test.cpp:7: conflicts with function declaration `int LsList()'
template_test.cpp:7: only constructors take base initializers
template_test.cpp:7: confused by earlier errors, bailing out



Can someone tell me what has changed with the compiler and why this code
doesn't compile anymore? Even better answer would be how should I write
this code in order to make it compile with gcc 3.2.

Thanks a lot!
Rade
P.S.
In case you are wondering:
[rtrimces@Vaio tests]# g++ --version
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: template(s) declaration with GCC3.2-7
  2003-04-22 16:34 template(s) declaration with GCC3.2-7 Rade Trimceski
@ 2003-04-22 16:48 ` John Love-Jensen
  2003-04-22 22:37   ` More template(s) errors " Rade Trimceski
  2003-04-23 18:58   ` please unsubscribe claudio
  0 siblings, 2 replies; 5+ messages in thread
From: John Love-Jensen @ 2003-04-22 16:48 UTC (permalink / raw)
  To: Rade Trimceski, gcc-help

Have you tried...

Line 4: class LsList : public std::list<_Tp> {

...?

--Eljay


^ permalink raw reply	[flat|nested] 5+ messages in thread

* More template(s) errors with GCC3.2-7
  2003-04-22 16:48 ` John Love-Jensen
@ 2003-04-22 22:37   ` Rade Trimceski
  2003-04-23  0:20     ` Oscar Fuentes
  2003-04-23 18:58   ` please unsubscribe claudio
  1 sibling, 1 reply; 5+ messages in thread
From: Rade Trimceski @ 2003-04-22 22:37 UTC (permalink / raw)
  To: gcc-help

Can someone demystify this error for me?

It comes out of a header file, and this did compile with gcc 2.96.

typedef hash_map<int, Neighbor_Entry *> Neighbors_Hash;

the compilation error is:

In file included from diffusion3/apps/gear/geo-routing.cc:11:
diffusion3/apps/gear/geo-routing.hh:187: syntax error before `;' token


Any ideas why I get the syntax error, and what it really means?

Thanks a lot!
Rade



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: More template(s) errors with GCC3.2-7
  2003-04-22 22:37   ` More template(s) errors " Rade Trimceski
@ 2003-04-23  0:20     ` Oscar Fuentes
  0 siblings, 0 replies; 5+ messages in thread
From: Oscar Fuentes @ 2003-04-23  0:20 UTC (permalink / raw)
  To: gcc-help

Rade Trimceski <rtrimces@mtu.edu> writes:

> Can someone demystify this error for me?
>
> It comes out of a header file, and this did compile with gcc 2.96.
>
> typedef hash_map<int, Neighbor_Entry *> Neighbors_Hash;
>
> the compilation error is:
>
> In file included from diffusion3/apps/gear/geo-routing.cc:11:
> diffusion3/apps/gear/geo-routing.hh:187: syntax error before `;' token
>
>
> Any ideas why I get the syntax error, and what it really means?

Well, the error message is not a great help on this case. What really
happens is that 'hash_map' is an unknown template for the compiler.

GCC 3.x comes with a new Standard C++ Library implementation, which is
far more conformant than the previous one. All standard C++ library
names are on namespace 'std'.

For this specific case, 'hash_map' is not a standard C++ library
template. However, the GNU implementors added it for supporting old
code (and as a nice extension, I guess). It's on namespace __gnu_cxx,
implemented on <ext/hash_map>.

I think this issues are explained on some README on the GCC
distribution or on the website. The 'std' namespace thing is something
every C++ developer should know since a long time ago, though.

-- 
Oscar

^ permalink raw reply	[flat|nested] 5+ messages in thread

* please unsubscribe
  2003-04-22 16:48 ` John Love-Jensen
  2003-04-22 22:37   ` More template(s) errors " Rade Trimceski
@ 2003-04-23 18:58   ` claudio
  1 sibling, 0 replies; 5+ messages in thread
From: claudio @ 2003-04-23 18:58 UTC (permalink / raw)
  To: gcc-help



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-04-23 18:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22 16:34 template(s) declaration with GCC3.2-7 Rade Trimceski
2003-04-22 16:48 ` John Love-Jensen
2003-04-22 22:37   ` More template(s) errors " Rade Trimceski
2003-04-23  0:20     ` Oscar Fuentes
2003-04-23 18:58   ` please unsubscribe claudio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).