Message-ID: <000e01c158c0$9b65f500$0101a8c0@hernan> From: "R. Grela" To: References: <007301c15846$1208b4c0$0101a8c0 AT hernan> <9qoubi$asj$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> Subject: RE: Compiling problem Date: Fri, 19 Oct 2001 14:06:46 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Reply-To: djgpp AT delorie DOT com If I try gxx -c test.h where in test.h I ve all the template code I receive: gcc.exe: Compilation of header file requested how works the new "exports" keyword ? Do you have a sample ? Thank you for your response! ----- Original Message ----- From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp To: Sent: Friday, October 19, 2001 7:13 AM Subject: Re: Compiling problem > R. Grela wrote: > > I'm trying to compile a template class, I don't know what I am doing wrong: > > I 've this: (it's the simplest test) > [...] > > --- test.cpp --- > > #include "test.h" > > > template > > test::test() > > { > > } > > --- end of test.cpp --- > > Here's your problem. It's a basic misunderstanding of how templates > work, in all but the very latest dialects of C++ (--> the new > "exports" keyword). > > One of the main differences between an ordinary class and a template > is that a template cannot usually have a separate implementation file > (like this test.cpp of yours) --- the whole implementation *must* be > #included into the code using the template, i.e. it should be in the > header file. Templates cannot be compiled separately. > > A quick fix would be to remove the #include test.h from your test.cpp, > and instead #include "test.cpp" at the end of test.h. Or just copy the > contents into there, right away. > -- > Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) > Even if all the snow were burnt, ashes would remain.