delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/03/14:41:48

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: problem using "templates"
Date: Mon, 03 Jan 2000 17:14:35 +0000
Organization: Customer of Planet Online
Lines: 57
Message-ID: <ldl17s01u8jd1oee6uuql2cdsrpp6dj0dc@4ax.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 991230155042 DOT 1790D-100000 AT is> <viRa4.6159$36 DOT 52788 AT carnaval DOT risq DOT qc DOT ca> <vvvvvvllpmiltbb6v30q4reahtjflvet77 AT 4ax DOT com> <386E51DC DOT 7577C2ED AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: modem-56.present.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news6.svr.pol.co.uk 946919938 2269 62.136.134.56 (3 Jan 2000 17:18:58 GMT)
NNTP-Posting-Date: 3 Jan 2000 17:18:58 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> > On which platform?
> 
> It doesn't matter.  The problem happens during compilation, and refers
> only to the C++ libraries.  There's nothing platform-specific in these
> two areas, AFAIK.

Eli, there is something not quite right here.  The following code
compiles fine in Linux but under DJGPP it fails to link:

/* test.cpp */
#include <iostream>

template <class T> class foo 
{
public :
  static int bar;
};
    
template <class T> int foo<T>::bar = 123;
    
int main()
{
  int i;

  i = foo<int>::bar;

  cout << "i=" << i << endl;
}                                         

In Linux:

$ g++ --version
2.95.2
$ g++ -Wall test.cpp -o test
$ ./test
i=123

In Dos/Windows:

D:\>gpp --version
2.952

D:\>gpp -Wall test.cpp -o test
d:/djgpp/tmp\ccuAyWLk.o(.text+0xb):test.cpp: undefined reference to
`foo<int>::bar'
collect2: ld returned 1 exit status


I just can't see how this program can compile with g++ on one platform
but not under DJGPP using the same gcc version.

And I don't see how the C++ libraries could be involved?

Also I noticed that the version numbers are quoted slightly
differently (2.95.2 vs 2.952) which seemed strange.

- Raw text -


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