mangle

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Thu Jul 1 20:03:31 PDT 2010


On Thu, 1 Jul 2010 19:34:09 -0700, Jonathan M Davis 
<jmdavisprog at gmail.com> wrote:
> 
> On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
> > On 7/1/2010 19:32, Jonathan M Davis wrote:
> > > By the way, why _does_ D mangle its names? What's the advantage? I
> > > understood that C++ does it because it was forced to back in the days
> > > when it was transformed into C code during compilation but that it's now
> > > generally considered a legacy problem that we're stuck with rather than
> > > something that would still be considered a good design decision.
> > > 
> > > So, why did D go with name mangling? It certainly makes stuff like stack
> > > traces harder to deal with. I've never heard of any advantage to name
> > > mangling, only disadvantages.
> > 
> > Because DMD is stuck with a C-age linker.
> 
> Well, I guess that it just goes to show how little I understand about exactly 
> how linking works when I don't understand what that means. After all, C doesn't 
> using name mangling. Does that mean that name mangling it meant as a namespacing 
> tool to ensure that no D function could possibly have the same linking name as a 
> C function?
> 
> - Jonathan M Davis

C doesn't require mangling because functions can't be overloaded. To 
make D (or C++) compatible with C linkers, symbol names need to be 
unique, so functions with identical names but different types need to be 
represented with different symbols.


More information about the Digitalmars-d mailing list