extern(C) names are being mangled; that's crazy, Walter says I'm crazy

Ethan gooberman at gmail.com
Sat Jul 27 03:05:53 UTC 2019


On Friday, 26 July 2019 at 21:34:29 UTC, Manu wrote:
> I'm pretty sure it's about both

100% this.

D can't claim complete 100% C interoperability if it can't 
generate symbols that a C compiler expects to find.

Here's the insane thing about all this, for all those playing at 
home.

Take Manu's example, but add two little "++" symbols. ie:

export extern(C++) void fun() {}

AND

mixin template M()
{
   export extern(C++) void fun() {}
}
mixin M!();

You know what pragma( msg, fun.mangleof ) prints for both of them?

The exact same symbol, of course. _Z3funv on Linux, ?fun@@YAXXZ 
on Windows.

What actual legit "this is why this is bad in a production 
environment" reason is there to work as expected for C++ but not 
for C?

--

Manu keeps bringing up getting colleagues using D. It's not 
difficult to find out who he works for. It's not difficult to 
imagine how good it would be for D if D would enter wide usage 
among his colleagues.

Looking through the bug report. "You can get the behaviour you 
wanted with this code hack." No. This *cannot* be the face of the 
D language. Simple stuff like this should Just Work(TM).


More information about the Digitalmars-d mailing list