How to make D resolve C++ symbols by mangling symbols with the Itanium ABI on Windows
user1234
user1234 at 12.de
Mon Feb 26 19:50:31 UTC 2024
On Monday, 26 February 2024 at 17:23:32 UTC, thumbgun wrote:
> [...]
> The name mangling differences between the Itanium ABI and the
> MSVC ABI are more significant than just the prefix. I only
> mentioned that the prefixes are different to show that dmd was
> actually trying to link against symbols mangled by the MSVC
> ABI, not the Itanium one. If I used pragma mangle then I would
> have to manually translate each C++ function (signature) and
> struct/class to what the Itanium ABI would mangle them to which
> is very error prone and time consuming. I'm going to read the
> dmd source code - and maybe make a fork - because it apparently
> only tries to link against MSVC mangled symbols on Windows and
> not other platforms.
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.
More information about the Digitalmars-d
mailing list