Why extern variables and functions within template/struct/class have a D mangling
Dicebot
m.strashun at gmail.com
Wed May 8 03:07:56 PDT 2013
On Wednesday, 8 May 2013 at 09:56:14 UTC, Andrej Mitrovic wrote:
> On 5/8/13, Dicebot <m.strashun at gmail.com> wrote:
>> Because they have namespace (class namespace) and can't be
>> mangled according to C rules. Exactly your example. You can't
>> have two "foo"'s there but any other naming scheme IS NOT C
>> mangling but some weird abomination that pretends to be it.
>> Thus
>> it is a compile-time error.
>
> Right, you may not be able to statically link with it but it's
> still a
> calling convention, so it's useful (for callbacks).
Well, that is one of rather inconvenient issues with D handling
of emitting symbols (this one kind of inherited from C++).
extern(X) defines both mangling and calling convention. You can't
have those separately now. Saying in one case it is both mangling
and ABI and in other one it is only ABY smells like broken
specification/implementation.
Actually I remember discussing this with Volt language team
recently. Currently relation between D type system and emitted
symbols is not that well-defined in spec and this is one of many
cases where it causes problems. I don't think it can be fixed
without some sort of overhaul.
More information about the Digitalmars-d
mailing list