delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/23/21:25:13

From: ryot AT bigfoot DOT com (George Ryot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP 2.95 Templates
Message-ID: <37ecba3c.8727013@news.clara.net>
References: <37E9501D DOT 3E95D5EA AT mail DOT retina DOT ar>
X-Newsreader: Forte Agent 1.5/32.452
X-No-Archive: yes
MIME-Version: 1.0
Lines: 36
Date: Thu, 23 Sep 1999 23:41:14 GMT
NNTP-Posting-Host: 195.8.91.152
X-Complaints-To: abuse AT clara DOT net
X-Trace: nnrp4.clara.net 938130074 195.8.91.152 (Fri, 24 Sep 1999 00:41:14 BST)
NNTP-Posting-Date: Fri, 24 Sep 1999 00:41:14 BST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> I think that I have a problem related to template instantiation,
> the following code :
> 

> // FILE rwfile.h and rwfile.cpp
> #include "smat.h"
> 
> class rwfile
> {
> ..
>     template <class T> int read(  smat<T> data);
> ..
> }

> compiles without problems, but the linker reports (I am using a RHIDE
> 1.4.7 project):
> 
> Error undefined reference to int rwfile::read( smat<int> )
> 
> any ideas?

Yes, you probably wanted to define read() in the header file rwfile.h

template <class T> int rwfile::read(smat<T> data)
{
    // ...
}

Rather than in rwfile.cpp where I assume that you defined it.

OTOH, if you have found a bug in gcc then it is better to reduce the
program to the minimum that causes the error then cut and paste that
verbatim, else it just leaves everybody guessing. :)
-- 
george

- Raw text -


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