How to make D resolve C++ symbols by mangling symbols with the Itanium ABI on Windows
thumbgun
thumbgun07 at gmail.com
Tue Feb 27 07:58:40 UTC 2024
On Monday, 26 February 2024 at 20:07:55 UTC, user1234 wrote:
> On Monday, 26 February 2024 at 19:50:31 UTC, user1234 wrote:
>> On Monday, 26 February 2024 at 17:23:32 UTC, thumbgun wrote:
>>> [...]
>>
>> I see. That would be extremely painful. Could CTFE help here ?
>>
>> ```d
>> string getRightMangling(alias T)()
>> {
>> return "todo" // ;)
>> }
>>
>> pragma(mangle, getRightMangling!(add))
>> extern(C++) int add(int lhs, int rhs);
>> ```
>>
>> That's not a serious suggestion but I'm still curious to see
>> how that would scale.
>>
>> Also that looks weird that the pragma refers to what it is
>> supposed to affect, not sure that would work, although in
>> theory D manages forward refs.
>
> Turns out that the forward ref is not a problem. Remains the
> question of writing a mangler working fast at compile time ;)
Although I'm not quite sure what available features are permitted
for CTFE, I'll definitely have a look at that. Johan raised an
important point though about calling conventions as they are
different between the Itanium and the MSVC ABIs. So even if DMD
can link against Itanium mangled symbols, it won't follow the
same calling convention.
Another alternative apart from compiling libraries from source
with MSVC would be to create a C API to wrap the C++ library but
that's also time consuming.
More information about the Digitalmars-d
mailing list