Bug 12854 – Cannot interface to C++ code with const class pointers

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-06-04T16:20:58Z
Last change time
2024-12-13T18:21:15Z
Assigned to
No Owner
Creator
Atila Neves
Moved to GitHub: dmd#17663 →

Comments

Comment #0 by atila.neves — 2014-06-04T16:20:58Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17663 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB