delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/06/20:53:43

From: Weiqi Gao <weiqigao AT a DOT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: template support in v 2.02
Date: Sat, 06 Feb 1999 19:46:05 -0600
Organization: CRL Network Services
Lines: 70
Message-ID: <36BCF05D.727BBEDF@a.crl.com>
References: <36BCCD3E DOT 23E88D5 AT bignet DOT net>
NNTP-Posting-Host: a116026.stl1.as.crl.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.0.34 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

John Soares wrote:
> 
> Hello:
> 
> I just downloaded v2.02 and it still does not seem to support
> templates(I mean just plain templates, not the STL library).

Strange, because my DJGPP v2.01 (g++ 2.7.2) from two years ago support
templates.  For example, the following simple code compiled with no
errors or warnings and executed as expacted:

===============================================
#include <iostream.h>

template <class T>
class A {
	T _t;
public:
	A(T t) : _t(t) {}
	T t() { return _t; }
};

int main()
{
	A<int> x(100);
	A<float> y(3.5);
	cout << x.t() << "\n" << y.t() << "\n";
	return 0;
}
===============================================

> Does v. 2.02 actually support templates or am I still doing something
> wrong.

I suspect that v2.02 (which uses G++ 2.8.x?) would support templates
more than v2.01.  But understand that the ANSI C++ standard was adapted
only a little more than a year ago, it is possible that not all of the
standard features are supported in the current implementation.

> I am trying to follow an example in a textbook and getting all
> kinds of syntax errors.

If you can provide a simple sample program that exhibit the error, I
guarantee you will get the problem addressed a lot sooner.

For example:

I tried to compile:
===============================================
/* junk.cc */
void main()
{
}
===============================================

with the command line
===============================================
gxx -Wall junk.cc
===============================================

and got the following error
=================================================================
junk.cc:2: warning: return type of 'main' changed to integer type
=================================================================

What's going on?

-- 
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019