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