const(Class) is mangled as Class const* const

Nathan S. no.public.email at example.com
Wed Aug 26 00:41:18 UTC 2020


On Monday, 27 March 2017 at 20:41:51 UTC, kinke wrote:
> 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'.

I just ran into this problem too. Is there some way around this 
with pragma(mangle)? Forking the 3rd-party library would be my 
last resort. If there's a way that I can write the declaration in 
D I would prefer to do that.


More information about the Digitalmars-d mailing list