delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/15/18:49:03

From: jbuck AT synopsys DOT com (Joe Buck)
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,gnu.g++.help
Subject: Re: templates
Date: 15 May 1997 16:46:20 GMT
Organization: Synopsys Inc., Mountain View, CA 94043-4033
Lines: 29
Message-ID: <5lfeks$8ef@hermes.synopsys.com>
References: <01bc5fc6$6d16b7e0$0b88099a AT dennis DOT worldonline DOT nl> <3379DF98 DOT 167E AT cs DOT fiu DOT edu> <337AF87A DOT 69F6 AT dundee DOT ncr DOT com DOT org>
NNTP-Posting-Host: atrus-84.synopsys.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Robin DOT Paterson AT dundee DOT ncr DOT com DOT org writes:
>	If you've got a g++ with the repo patch, _then_ it
>	will work like the Sun compiler, or the NCR C++ compiler
>	as these guys use a repository.

No, it's not quite the same; the compiler still needs to see the template
definitions.  With Sun's compiler, and cfront, the link-time template
expansion will compile files never seen in the original compilation.

However, the original poster was assuming that the behavior of cfront,
duplicated in SunSoft C++, is the standard.  It's not; the (draft)
standard makes no promises that the linker will go off and look in foo.C
for template definitions if you included foo.h.

In any case, the repo patch has some problems: it may require ten passes
to completely build STL programs, and it prevents you from building reusable
libraries without the risk of getting multiply defined symbols.

2.8.0 has a new solution, which is basically the same one Borland C++ uses
(roughly, common blocks for template expansions: each .o file gets a
template expansion of used functions but the linked executable gets only
one copy, eliminating duplicates).



-- 
-- Joe Buck	http://www.synopsys.com/pubs/research/people/jbuck.html

Help stamp out Internet spam: see http://spam.abuse.net/spam/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019