www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - template instantiation

↑ ↓ ← Christof Meerwald <cmeerw web.de> writes:
In the following test-case, the template function isn't instantiated (linker
complains with "Symbol Undefined ?f  YAHH Z (int cdecl f(int ))"):

  template<class T> int f(T a);

  int main(int argc, char *argv[])
  {
    int a = 0;
    return f(a);
  }

  template<class T> int f(T a)
  {
    return 0;
  }


and DM doesn't support explicit template instantiation, e.g.

  template<class T>
  struct A
  {
    void f()
    { }
  };

  template A<int>;


bye, Christof

-- 
http://cmeerw.cjb.net                          Jabber: cmeerw jabber.at
mailto cmeerw at web.de                   ICQ: 93773535, Yahoo!: cmeerw

...and what have you contributed to the Net?
Oct 15 2001
↑ ↓ John Fletcher <J.P.Fletcher aston.ac.uk> writes:
Christof Meerwald wrote:

 In the following test-case, the template function isn't instantiated (linker
 complains with "Symbol Undefined ?f  YAHH Z (int cdecl f(int ))"):

   template<class T> int f(T a);

   int main(int argc, char *argv[])
   {
     int a = 0;
     return f(a);
   }

   template<class T> int f(T a)
   {
     return 0;
   }

 and DM doesn't support explicit template instantiation, e.g.

   template<class T>
   struct A
   {
     void f()
     { }
   };

   template A<int>;

 bye, Christof

 --
 http://cmeerw.cjb.net                          Jabber: cmeerw jabber.at
 mailto cmeerw at web.de                   ICQ: 93773535, Yahoo!: cmeerw

 ...and what have you contributed to the Net?

You don't say what compiler options you used. When I get messages like this I retry with -XD added. John
Oct 16 2001
↑ ↓ "Walter" <walter digitalmars.com> writes:
Yes, -XD will make it work with the existing compiler, but I wanted to fix
it so it worked automatically. -Walter

John Fletcher wrote in message <3BCBF5E9.83FE7752 aston.ac.uk>...
Christof Meerwald wrote:

 In the following test-case, the template function isn't instantiated


 complains with "Symbol Undefined ?f  YAHH Z (int cdecl f(int ))"):

   template<class T> int f(T a);

   int main(int argc, char *argv[])
   {
     int a = 0;
     return f(a);
   }

   template<class T> int f(T a)
   {
     return 0;
   }

 and DM doesn't support explicit template instantiation, e.g.

   template<class T>
   struct A
   {
     void f()
     { }
   };

   template A<int>;

 bye, Christof

 --
 http://cmeerw.cjb.net                          Jabber: cmeerw jabber.at
 mailto cmeerw at web.de                   ICQ: 93773535, Yahoo!: cmeerw

 ...and what have you contributed to the Net?

You don't say what compiler options you used. When I get messages like

retry with -XD added.

John

Oct 16 2001
↑ ↓ Christof Meerwald <cmeerw web.de> writes:
On Tue, 16 Oct 2001 11:42:43 -0700, Walter wrote:
 Yes, -XD will make it work with the existing compiler, but I wanted to fix
 it so it worked automatically. -Walter

Thanks for fixing it.
 and DM doesn't support explicit template instantiation, e.g.



and the '-XI' command line option doesn't seem to work for class templates.
   template<class T>
   struct A
   {
     void f()
     { }
   };



If I compile it with 'sc -c -cod "-XIA<int>"' no code for the instantiation is generated. bye, Christof -- http://cmeerw.cjb.net Jabber: cmeerw jabber.at mailto cmeerw at web.de ICQ: 93773535, Yahoo!: cmeerw ...and what have you contributed to the Net?
Oct 16 2001
↑ ↓ "Walter" <walter digitalmars.com> writes:
The XI is a holdover from the bad old days before comdat's. Do you need it?

"Christof Meerwald" <cmeerw web.de> wrote in message
news:9qi0v7$2gvh$1 digitaldaemon.com...
 On Tue, 16 Oct 2001 11:42:43 -0700, Walter wrote:
 Yes, -XD will make it work with the existing compiler, but I wanted to


 it so it worked automatically. -Walter

Thanks for fixing it.
 and DM doesn't support explicit template instantiation, e.g.



and the '-XI' command line option doesn't seem to work for class

   template<class T>
   struct A
   {
     void f()
     { }
   };



If I compile it with 'sc -c -cod "-XIA<int>"' no code for the

 is generated.


 bye, Christof

 --
 http://cmeerw.cjb.net                          Jabber: cmeerw jabber.at
 mailto cmeerw at web.de                   ICQ: 93773535, Yahoo!: cmeerw

 ...and what have you contributed to the Net?

Oct 16 2001
↑ ↓ → Christof Meerwald <cmeerw web.de> writes:
On Tue, 16 Oct 2001 15:12:08 -0700, Walter wrote:
 The XI is a holdover from the bad old days before comdat's. Do you need it?

I would prefer the standard C++ explicit template instantiation. STLport's I/O stream library makes heavy use of it (I was just looking for an alternative). bye, Christof -- http://cmeerw.cjb.net Jabber: cmeerw jabber.at mailto cmeerw at web.de ICQ: 93773535, Yahoo!: cmeerw ...and what have you contributed to the Net?
Oct 17 2001