🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #35

Template problems

#35
From: Peter K. Campbell
Date: Fri, 31 Jul 1992 12:48
71 lines
2856 bytes
Hello out there.

Before I start, some background.  I have compiled & installed gcc 2.2.2
& libg++ 2.2 on a sparc-sun-sunos4.1.1, and been using gcc with no
problems on normal C code.

I have just received a package which is meant to be able to compile
in Sabre, Sun & AT&T (2.1) C++, and I've successfully compiled it on
using the latter.  I thought that seeing as I like GNU and are just
beginning to learn C++ that I'd have a bit of fun trying to get the
package to work with GNU.

Unfortunately, I didn't even get past the include files before I started
getting errors everywhere.  I checked the errors and they all seemed
to be concerned with the one type of construct - something of the form

	Template Name<X>

with the error message being:

	parse error before `<'

There are a few dozen of these errors - e.g. for

	Template Error___You_are_not_compiling_with_vpp<X> {}

They also seem to cause related errors - e.g.

...
	Template Vstr<X>
	{
 	Declare:
  	{
 	    class Vstr<X> : public PVstr
	    {
	    public:
	      // constructors
	      inline Vstr<X>();
	      inline Vstr<X>(const o_vstr vstr);
	      inline Vstr<X>(const Vstr<X>& vstr);
	      inline Vstr<X>(o_u4b hint);
	      inline Vstr<X>(o_u4b hint, o_bool ignored);
	      inline Vstr<X>(const X* data, o_u4b count);
	      inline Vstr<X>(const X* data, o_u4b count, o_bool ignored);
...

gives "parse error before '<'" for the line with the Template on it,
and 
	parse error before `X'
for every line starting with inline _except_ the inline Vstr<X>();

No-one around here knows much about templates (and nothing about this form
of template), and there's nothing like this in any of the books I've scanned.

However, as I said above this compiled without problems under AT&T,
which seems to indicate that the code is ok, and seeing as it was all
right under 2.1 I would have expected gcc/g++ 2.2.2 to handle it ok.

So, could anyone please tell me
	(1) What this form of template is,
	(2) Why is g++/gcc giving all of these parse errors,
	(3) If this is a FAQ (& my apologies if it is, like I said, I've
		just started learning C++ & only just found this newsgroup)
		where can I get the FAQ answers is?


Thanks in advance.

Peter K. Campbell
p.campbell@trl.oz.au.
#include <std.disclaimer>
Technical Details
Message-ID: <1992Jul31.124809.25121@trl.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!caen!sdd.hp.com!mips!mips!munnari.oz.au!trlluna!titan!tardis!peter

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!caen!sdd.hp.com!mips!mips!munnari.oz.au!trlluna!titan!tardis!peter
From: peter@tardis.trl.OZ.AU (Peter K. Campbell)
Subject: Template problems
Message-ID: <1992Jul31.124809.25121@trl.oz.au>
Summary: code compiles under at&t, not gnu
Keywords: template, g++, who uses these anyhow
Sender: root@trl.oz.au (System PRIVILEGED Account)
Organization: Telecom Research Labs, Melbourne, Australia
Date: Fri, 31 Jul 1992 12:48:09 GMT
Lines: 71