Fun with extern(C++)

Manu via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 26 04:59:35 PST 2016


Okay, new issues:

  extern(C++) class Base {}
  class Derived : Base {}

It seems that 'Derived' is implicitly a C++ class... I guess that
seems okay, but this leads to a series of edges where things start
breaking down...

  pragma(msg, BaseClassesTuple!Derived);  -> Error: tuple index 0 exceeds 0

Okay... that's broken. But I need to know it's base class.

  pragma(msg, BaseTypeTuple!ComponentType);  -> (in Base)

Base is reported as an interface? That's weird... and get's me wondering:

  interface Iface {}
  class Derived2 : Base, Iface {}

-> Error: C++ class 'Derived2' cannot implement D interface 'Iface'

Hmmm. I wonder if this will cause problems...
Is it impossible to support a C++ class implementing a D interface?
Users will need to declare extern(C++) interfaces anytime they want to
use it on any class with a C++ base class?

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.

At very least, I need BaseClassesTuple to work with C++ classes. I
suspect this is probably fixable?


More information about the Digitalmars-d mailing list