const(Class) is mangled as Class const* const

kinke via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 27 13:41:51 PDT 2017


On Monday, 27 March 2017 at 20:09:35 UTC, Walter Bright wrote:
> Whichever way it is mangled will gore someone's ox. D went with 
> the simplest mangling solution, which is to mangle all C++ 
> const pointers as "head const".
> [...]
> I suggest a simpler way - declare the C++ side of the D 
> interface in a way that matches the way D mangles it. It's 
> always been true that in order to interface D with C++ you'll 
> need to be a bit flexible on the C++ side.

Unfortunately, it's almost always the other way around - D code 
trying to interop with one of the gazillions existing C++ libs, 
and nobody wants to maintain his own fork with D-compatible glue 
interfaces. How often did you use `const T *const` vs. `const T 
*` in your C++ headers? ;) I think this would be a tiny change 
for D, breaking almost no code and well worth the reduction in 
required 'flexibility on the C++ side'.


More information about the Digitalmars-d mailing list