Fun with extern(C++)

Manu via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 26 07:53:39 PST 2016


On 27 January 2016 at 00:37, Kagamin via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Tuesday, 26 January 2016 at 12:59:35 UTC, Manu wrote:
>>
>> Hmmm. I wonder if this will cause problems...
>> Is it impossible to support a C++ class implementing a D interface?
>
>
> D interfaces are implicitly convertible to Object.

How does that work?
I've never really used classes in D.

>> I kinda hoped that having a C++ class at the bottom of the stack would
>> just be a detail once D classes are derived from it, but it seems that any
>> class derived from a C++ base is placed into a separate world.
>
>
> D classes are derived from Object class.

So, you're saying that if you have an 'I' pointer, which may be
implemented by a C++ class, it still needs to be able to cast to
Object, and therefore fails? I wonder if a C++ class could somehow be
promoted to a D class when being derived in D, by having an Object
placed somewhere. 'this' adjustment might be required at that point
though, and that's not really nice in C++.


More information about the Digitalmars-d mailing list