Mail Archives: djgpp/2001/10/19/13:11:32
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 <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
To: <djgpp AT delorie DOT com>
Sent: Friday, October 19, 2001 7:13 AM
Subject: Re: Compiling problem
> R. Grela <rgrela AT ciudad DOT com DOT ar> 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 <class T>
> > test<T>::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.
- Raw text -