[MUD-Dev] [TECHNICAL] How to generate pre-processor output (template problem).

Oliver Jowett icecube at ihug.co.nz
Sat May 29 14:40:20 CEST 1999


On Thu, 27 May 1999, Ben Greear wrote:

> I added a cute little templated array class, and everything works like a charm
> on my egcs RH 6.0 Linux box.  However, my primary mud server is BSD, and it's
> compiler is g++ 2.7.2.  It gets all the way to the end and then complains about
> a missing symbol (*puke*).  To add to the fun, its mangled so badly I haven't a
> real clue what it really is supposed to be.  Also, I have neither root nor the
> permission to install a new compiler or any other useful software
> on the BSD box.
> 
> The interesting thing is that it is listed as line 905 in a .h file that
> contains only about 100 lines.  I imagine that is because the #include
> that pulls in the template class....

2.7.2 is really "interesting" to get working correctly with templates..

There are several possible ways to get it working; from memory we did:

- make sure that everything that uses the template pulls in the entire
  template code (ie. you have to declare the whole template body in the
  header)
- put a #pragma interface at the top of each template header
- have a file with #pragma implementation "somefile.h", #include
  "somefile.h" lines for every template header you use
- in the body of that file, reference all the template instantiations you
  need:

  template class list<int>; // I think this is the syntax
  template class map<String, SomeOtherObject>;

  etc.

- compile everything with -fexternal-templates

Then, in theory, g++ should only generate non-inline template code in the
one place - the file with all the #pragma implementation lines. Maybe :)

I moved to using egcs a while back, which has its own set of template
peculiarities, so YMMV.

--
Oliver Jowett - icecube at ihug.co.nz - http://homepages.ihug.co.nz/~icecube/
KeyID: 1024/679D94C5  Fingerprint: CD94 5270 E2F4 339F 6A90 05C9 9DE4 EECC



_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the mud-dev-archive mailing list