D:
extern(C++) interface DClass { int getIndex() const; }
extern(C++) void useObj(in DClass dclass); //I also tried const DClass
C++:
struct DClass { virtual int getIndex() const = 0; }
void useObj(const DClass* dclass); //DClass* works though!
The code above refuses to link. Whether not the D declaration for useObj is marked `const`, or `in` makes no difference, either way the C++ declaration can't have const in it.
OTOH, if instead it's `ref const(DStruct)` and `const DStruct&` (or the equivalent pointer declarations it links fine.
I'm aware of the differences between const in C++ and D, but the above makes it worse: D can happily think it's const while the C++ code is free to do whatever it wants without even having to use const_cast.
Comment #1 by robert.schadek — 2024-12-13T18:21:15Z