A question about C++ interop

kinke noone at nowhere.com
Sun Mar 29 17:32:59 UTC 2020


On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote:
> So what do I need to declare in the D file for it to match the 
> library entry? Thanks!

This is similar to 
https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked 
around the same way by messing manually with the mangled name, if 
you can't adapt the C++ side. The actual problem is that you 
can't express a mutable reference to a const class object (as 
opposed to a struct) in D (`const Y` is a const reference to a 
const Y object).

> (This problem somehow does not appear on Linux where the 
> library file is compiled with gcc, though)

The Itanium C++ mangling doesn't differentiate between:

void foo(const Y *);       // what you have on the C++ side
void foo(const Y * const); // corresponds to D `void foo(const Y)`



More information about the Digitalmars-d-learn mailing list