* Templates in digital C++
@ 1998-02-24 5:00 Chris Fury
1998-03-11 5:00 ` Jeff Sullivan
0 siblings, 1 reply; 2+ messages in thread
From: Chris Fury @ 1998-02-24 5:00 UTC (permalink / raw)
Eeek. I can't figure out why my code isn't compiling right in
digital C++. It works fine in every other compiler I try it with
(sgi, g++)
Here's my setup...
I have a directory structure (I don't know if this important for
the c++ repository stuff) like this
/ (this is the root directory for my source tree)
/Makefile.def - a gnu makefile that defines my platform types, etc.
/Makefile
/src
/source1
/source2 - these are my source dirs
Now, I create a class that's a template in one of my source dirs
template.hh
template<class T> class TestTemplate {
public:
TestTemplate(void);
};
template.cc
template<class T>
TestTemplate::TestTemplate(void)
{
cout << "pppphhhhhppppt" << endl;
}
If I try to make this (with some reference to it in another file, of
course), it won't compile, I get a linker error telling me it can't find
the function definition. If I try to use the -ptr CC option to make
ONE cxx_repository it doesn't seem to work.
If I put the function definition right in the .hh file, or if I
make all the functions in the class inline it does work.
But this isn't acceptable. I have virtual functions in my templates,
and I have to define the virtual functions INSIDE the class definition
for it to compile and recognize it.
Ack. I guess what I'm trying to ask here is how do templates work
in digital C++? What kind of voodoo do I need to do to make them
work for me?
I know this example is probably confusing... Email me and I'll try
to clear it up.
--
Short, simple, consise,
haiku is easy to write.
Write me one, for fun.
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Templates in digital C++
1998-02-24 5:00 Templates in digital C++ Chris Fury
@ 1998-03-11 5:00 ` Jeff Sullivan
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Sullivan @ 1998-03-11 5:00 UTC (permalink / raw)
This issue was handled offline, but I am posting the resolution
here so that it may help others. The answer came from someone
else in the C++ group who worked the issue with Chris...
The problem turned out to be that Chris had a source
and include hierarchy in his application. Digital's template
automatic instantiation scheme requires that the
template repository files get created in a directory or
directories so that the final link can know where they are.
Once the makefile was changed to use the -ptr option
to specify the complete path name of where all the
template repository files should go and -I flags were added so
that the pre-linker could find the relevant include files,
the application compiled and linked successfully.
For any Digital C++ users with similar problems, Section
5.2.9.2 "Building an Application" from the DEC C++ Version
5.6 Using Guide covers this topic.
-Jeff
--
Jeff Sullivan | Digital Equipment Corp | E-mail: jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/2X29 | sullivan@decc.enet.dec.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-03-11 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-24 5:00 Templates in digital C++ Chris Fury
1998-03-11 5:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox