home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11759 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  1.8 KB

  1. Xref: sparky comp.lang.c++:11759 gnu.g++.help:1059
  2. Path: sparky!uunet!idacrd!purtill
  3. From: purtill@idacrd.UUCP (Mark Purtill)
  4. Newsgroups: comp.lang.c++,gnu.g++.help
  5. Subject: Re: porting to g++ (from other "dialects")
  6. Message-ID: <1526@idacrd.UUCP>
  7. Date: 29 Jul 92 22:21:06 GMT
  8. References: <1992Jul28.160935.11839@cs.ucla.edu> <1549upINN876@agate.berkeley.edu>
  9. Organization: idacrd, princeton, nj
  10. Lines: 27
  11.  
  12. jbuck@forney.berkeley.edu (Joe Buck) writes:
  13. >2.  The template implementation is still buggy, but it's been improving
  14. >rapidly (2.2.2 is much better than 2.1).  g++ doesn't implement the cfront
  15. >hack that lets you declare template functions in Foo.h and define them in
  16. >Foo.c, and then do a hidden #include of Foo.c so everything will work.  If
  17. >you do this in g++ you'll need to #include "Foo.c".
  18.  
  19.     That isn't actually quite how cfront works.  What it does is
  20. generate a small file along the lines of:
  21.  
  22.     #include "Foo.h"
  23.     #include "Foo.c"
  24.     static Foo<int> _dummy_ ;
  25.  
  26. and then compiles THAT, so as to generate one copy of all of the
  27. relevant functions.  This means, for instance, that "Foo.h" had better
  28. not depend on anything else having been included before it, and that
  29. you have to pass all the cpp/cfront/cc flags to the load phase (since
  30. that's where the small file is generated and compiled).  In practice,
  31. this all seems to be not worth the effort (especially when class Foo
  32. is declared in "Bar.h" and defined int "Bar.C" and "Bar2.C", when you
  33. have to start messing around with configuration files to tell the
  34. template linker thingee where everything is).  It's especially fun
  35. when you want the same code to compile under gcc as well....
  36.  
  37. ^.-.^ Mark Purtill, purtill@ccr-p.ida.org; uunet!idacrd!purtill. (609)497-0526.
  38. ((")) \@_: IDA/CCR-P, Thanet Road, Princeton NJ 08540;           (609)924-4600.
  39.