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
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.