extern(C++) multiple inheritence

Manu via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 25 21:09:24 PST 2016


On 26 January 2016 at 15:02, Manu <turkeyman at gmail.com> wrote:
> On 24 January 2016 at 20:40, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 1/22/2016 5:46 PM, Manu via Digitalmars-d wrote:
>>>
>>> I brought a work laptop home this weekend in anticipation ;)
>>
>>
>> Here ya go:
>>
>>   https://github.com/D-Programming-Language/dmd/pull/5364
>>
>> Be wary of:
>>
>>   https://issues.dlang.org/show_bug.cgi?id=15589
>>
>> and use the workaround as necessary. This is lower priority, so I won't be
>> dealing with it for a bit.
>
> Next blocker: https://issues.dlang.org/show_bug.cgi?id=15610
>
> C++ methods with multiple-inheritence expect that 'this' is a pointer
> to the base class that introduced the function.
> When using C++ 'interface's, which C++ just treats like normal
> multiple-inheritence, C++ expects that the 'this' pointer is adjusted
> to the offset of the interface's vtable.
>
> If I have:
> extern(C++) interface Interface { voif f(); }
> extern(C++) class C : Base, Interface
> {
>   void f();
> }
>
> Calling c.f(), D is passing 'this' unaltered, but C++ expects 'this'
> is a pointer to 'Interface', and then it crashes accessing members at
> incorrect offsets.

Also, bugs in the name mangling are really becoming a problem. I have
logged several bugs of this sort, but my code has developed a serious
case of pragma(mangle, "??XYZ.....") appearing all over the place to
make it link.

https://issues.dlang.org/show_bug.cgi?id=15608
https://issues.dlang.org/show_bug.cgi?id=15576
https://issues.dlang.org/show_bug.cgi?id=15473

This is not a blocker, but I think it's high priority.


More information about the Digitalmars-d mailing list