Re: [OFF-TOPIC] C++ template question
On Fri, 31 Oct 1997, Shaleh wrote:
> This is mostly off topic but....
>
> How do you compile a template class into an object file WITHOUT
> instantiating it??? g++ happily compiles the .o file but bombs out when
> it tries to link later. Any suggestions happily accepted. Either to
> the list or me personally.
There are only two possible things you could want, I'm not sure which:
1) Cause the compiler to include an instance of the template in a
specific .o file:
#include <vector>
template class vector<int>;
gcc t.cc
2) Prevent the compiler from including an instance of any template in
any .o file
#include <vector>
vector<int> A;
gcc -fno-implicit-templates t.cc
You will want to use a combination of the two above schemes if your
program has a number of tempaltes. Make one file that contains all of the
template instances explicitly instanciated and compile it without
-fno-implicit-templates. Use -fno-implicit-templates on the rest of your
modules.
Jason
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: