www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/22/07:22:22

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
Subject: Re: Authors of DJGPP / GCC - #export needed !
Date: 22 Jan 2001 12:17:43 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 31
Message-ID: <94h8d7$jau$1@nets3.rz.RWTH-Aachen.DE>
References: <94ejfb$5a5$1 AT info DOT cyf-kr DOT edu DOT pl>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 980165863 19806 137.226.32.75 (22 Jan 2001 12:17:43 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 22 Jan 2001 12:17:43 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In comp.os.msdos.djgpp Rafal Maj <maj_rafal AT poczta DOT onet DOT pl> wrote:

> By the way... why is it realy so incredibly hard to implement ?

Because it breaks in a fundamental way how a compiler works together
with the linker.  

A template isn't really source code: it's just a recipe for making
code, in a way, with the details depending on the particular type you
instantiate the template with.  The fundamental problem is: _when_ is
this code going to be compiled?

You can't usually compile the implementation source file on its own,
because you don't know which types the template will be inst'ed with,
elsewhere.  But at the place where the code *is* used, your approach
with a separate implementation file tries to hide the implementation,
so it can't be compiled there, either.

So both .o files reach the linker, but the template never was compiled
for the particular type you used it with ---> the linker sees this and
barfs.

The '-frepo' flag of GCC tries to get around another, related aspect
of templates, by causing compilation steered by the linker. I.e. as
the linker sees that templated code is not compiled in any of the
modules linked in, it asks the compiler to compile those templates,
and then redoes the linking, until all the missing template
implementations are resolved.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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