Article View: comp.sys.sgi.bugs
Article #100Re: C++ template "already defined" error - any ideas?
From: Barbara Anderson-Zayat
Date: Thu, 21 Mar 1996 17:07
Date: Thu, 21 Mar 1996 17:07
41 lines
1600 bytes
1600 bytes
Peter Foldiak (pf2@st-andrews.ac.uk) wrote:
: When I try to compile the files below on a SG Indy (Irix 5.3) I get the
: following error:
: ----
: % CC main.c list.c
: main.c:
: "list.h", line 1: error(3328): class template "list" has already been
: defined
: template<class T> class list {
: ^
: 1 error detected in the compilation of "main.c".
: list.c:
: %
: ----
: (By the way, how do I find out what error(3328) is in more detail?)
: If I concatenate list.c and main.c into a file called listmain.c,
: and compile with
: % CC listmain.c
: %
: the error message disapprears! So I guess it has something to do
: with the bits being in separate files.
: Also, if the files contain no templates there is no error.
: Could anyone please help? Any ideas?
: Is there something special with including headrers when I use templates?
: Thanks!
Try including this in list.h ...
#ifdef __LIST_H_
#define __LIST_H_
// contents of list.h
#endif
It sounds like somehow your list.h is getting included twice.
Technical Details
Message-ID:
<4is2ck$g7b@news3.cts.com>Path:
arc1-ca.pugleaf.net!newshub.cts.com!not-for-mailReferences:
<4in2p7$27b@calvin.st-and.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newshub.cts.com!not-for-mail From: baz@cts.com (Barbara Anderson-Zayat) Newsgroups: comp.sys.sgi.bugs,comp.sys.sgi.apps,comp.sys.sgi.misc,comp.lang.c++ Subject: Re: C++ template "already defined" error - any ideas? Followup-To: comp.sys.sgi.bugs,comp.sys.sgi.apps,comp.sys.sgi.misc,comp.lang.c++ Date: 21 Mar 1996 17:07:32 GMT Organization: CTS Network Services (CTSNET), San Diego, CA Message-ID: <4is2ck$g7b@news3.cts.com> References: <4in2p7$27b@calvin.st-and.ac.uk> NNTP-Posting-Host: crash-i2.cts.com