Re: How do linkers deal with C++ duplicate code?

saroj@bear.com
22 Aug 1998 23:29:30 -0400

          From comp.compilers

Related articles
How do linkers deal with C++ duplicate code? johnl@iecc.com (John R Levine) (1998-08-20)
Re: How do linkers deal with C++ duplicate code? johnmce@world.std.com (1998-08-20)
Re: How do linkers deal with C++ duplicate code? stes@mundivia.es (David Stes) (1998-08-20)
Re: How do linkers deal with C++ duplicate code? urs@cs.ucsb.edu (Urs Hoelzle) (1998-08-20)
Re: How do linkers deal with C++ duplicate code? dlmoore@molalla.net (David L Moore) (1998-08-22)
Re: How do linkers deal with C++ duplicate code? dwight@pentasoft.com (1998-08-22)
Re: How do linkers deal with C++ duplicate code? stes@mundivia.es (David Stes) (1998-08-22)
Re: How do linkers deal with C++ duplicate code? saroj@bear.com (1998-08-22)
Re: How do linkers deal with C++ duplicate code? jacob@jacob.remcomp.fr (1998-08-22)
Re: How do linkers deal with C++ duplicate code? ian@cygnus.com (1998-08-22)
Re: How do linkers deal with C++ duplicate code? mrs@kithrup.com (1998-08-22)
Re: How do linkers deal with C++ duplicate code? mrs@kithrup.com (1998-08-22)
Re: How do linkers deal with C++ duplicate code? bowdidge@watson.ibm.com (Robert Bowdidge) (1998-08-24)
Re: How do linkers deal with C++ duplicate code? joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-08-25)
[2 later articles]
| List of all articles for this month |
From: saroj@bear.com
Newsgroups: comp.compilers
Date: 22 Aug 1998 23:29:30 -0400
Organization: Deja News - The Leader in Internet Discussion
References: 98-08-147 98-08-152
Keywords: C++, linker

John R Levine <johnl@iecc.com> writes:
> > How do linkers deal with C++ duplicate code?


    Urs Hoelzle <urs@cs.ucsb.edu> wrote:
> The short answer: not very well...


> >-- Templates and extern inline. ...


> Most aren't even as clever as that. For extern inlines, many
> compilers output bodies (and vtables) only when they see the body of
> the first virtual function in the class. Hopefully that function is
> defined in the .cpp file and thus isn't duplicated. (But many C++
> compilers happily duplicate vtables and inlines if the first virtual
> happens to be inline, i.e., has a body in the .h file.)


No, compilers use first non-inline, non-pure virtual function file
to output the vtable. If there is no such function, then it may be
duplicated. So it is a good idea to have at least one non-inline,
non-pure virtual function in a .cc (or, .cpp) file.


    -- Saroj Mahapatra
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.