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

zalman@netcom.com (Zalman Stern)
31 Aug 1998 03:22:42 -0400

          From comp.compilers

Related articles
[9 earlier articles]
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)
Re: How do linkers deal with C++ duplicate code? dlmoore@molalla.net (David L Moore) (1998-08-30)
Re: How do linkers deal with C++ duplicate code? zalman@netcom.com (1998-08-31)
| List of all articles for this month |
From: zalman@netcom.com (Zalman Stern)
Newsgroups: comp.compilers
Date: 31 Aug 1998 03:22:42 -0400
Organization: ICGNetcom
References: 98-08-147 98-08-161 98-08-181 98-08-198
Keywords: linker, C++, design

David L Moore (dlmoore@molalla.net) wrote:
: Unfortunately, you cannot do both without a module concept. There are
: really two types of error you want to detect:


: type 1:


: File 1:
: float foo(int i); // no definition in this file


: File 2:
: double foo(int i) {} // here is the definition - oops


: and


: File 1:
: float foo(int i) {} // definition


: File 2:
: double foo(int i) {} // second definition




: Original C++ style mangling (no return type) detects error 2, and not
: error 1.


: Variant mangling (mangle the return type too) detects error 1 but not
: error 2.


Generate two symbols for the function definition. One that has the return
type in the mangling, one that doesn't. The symbol with the return type is
the one that is referenced to call the funtion. The one without the return
type is the most efficient "NULL definition" one can use that will flag a
multiply defined error if two of them show up.


And yeah, its long past time we stopped hacking up ancient linkers to deal
with C++ and started writing ones that do the job properly. (Including
using much more compact representations of mangled names.)


-Z-
--


Post a followup to this message

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