Article View: gnu.g++.bug
Article #13512.3.3: templates and #pragma interface
From: Klamer Schutte
Date: Thu, 07 Jan 1993 14:23
Date: Thu, 07 Jan 1993 14:23
50 lines
1861 bytes
1861 bytes
The #pragma interface / #pragma implementation scheme does not work correct
with template classes. I have the header file:
------------ tm1.h ------------
#pragma interface
template<class T>
class A
{
public:
A()
{ }
};
class B
{
public:
B()
{ }
};
------------ EOF -------------
and the implementation file:
------------ tm1.cc ---------
#pragma implementation
#include "tm1.h"
static A<int> *ai;
------------ EOF ------------
In the object file should the constructor of A<int> and B both be globally
defined; however, the A<int> constructor is static:
0 klamer@mi7 13:16 68> g++ -v -c tm1.cc
Reading specs from /usr/local/lib/gcc-lib/sun4/2.3.3/specs
gcc version 2.3.3
/usr/local/lib/gcc-lib/sun4/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix tm1.cc /tmp/cca11095.i
GNU CPP version 2.3.3 (sparc)
/usr/local/lib/gcc-lib/sun4/2.3.3/cc1plus /tmp/cca11095.i -quiet -dumpbase tm1.cc -version -o /tmp/cca11095.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
as -o tm1.o /tmp/cca11095.s
0 klamer@mi7 13:17 69> nm tm1.o
00000000 T B::B()
00000024 t A<int>::A()
00000048 b _ai
00000000 t gcc2_compiled.
The #pragma interface part does work to prevent generation of the templates
in files which do not have a matching #pragma implementation.
Klamer
Technical Details
Message-ID:
<9301071223.AA05367@mi.el.utwente.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!mi.eltn.utwente.NL!klamerShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!mi.eltn.utwente.NL!klamer From: klamer@mi.eltn.utwente.NL (Klamer Schutte) Subject: 2.3.3: templates and #pragma interface Message-ID: <9301071223.AA05367@mi.el.utwente.nl> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 7 Jan 1993 14:23:16 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 51