Why can't we use strings in C++ methods?

Imperatorn johan_forsberg_86 at hotmail.com
Sat Nov 4 14:45:18 UTC 2023


On Saturday, 4 November 2023 at 14:33:56 UTC, Basile B. wrote:
> On Saturday, 4 November 2023 at 13:51:20 UTC, Dadoum wrote:
>> [...]
>
>
> The type simply cannot be mangled using the C++ mangler as it 
> does not exist over there. You might have the impression that 
> this should be allowed, e.g as an extension, but keep in mind 
> that `extern(C++)` is firstly designed to link against object 
> produced by a C++ compiler.
>
> Now why this works in `extern(C)` ? Because C does not mangle 
> the parameters, a function linkage name is simply its 
> unqualified name, so linking will work even if the parameter 
> types are specific  to D.
>
> Now there is still the question whether the `extern(C)` code 
> will work as expected or not.

Could the mangling be provided with pragma and made to work?


More information about the Digitalmars-d-learn mailing list