D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16289 - no extern(C++) mangling for size_t/unsigned long parameters
Summary: no extern(C++) mangling for size_t/unsigned long parameters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 normal
Assignee: No Owner
URL:
Keywords: C++, mangling
Depends on:
Blocks:
 
Reported: 2016-07-18 12:06 UTC by Martin Nowak
Modified: 2020-02-21 02:17 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2016-07-18 12:06:57 UTC
The C++ mangler conflates mangling for unsigned, unsigned long, and unsigned long long depending on the target architecture. Those are separate manglings in C++, independent of their target size.
This leads to several linking problems w/ C++ code, in particular when a size_t parameter is involved.
We already have some places in cppmangle where we properly handle Id.__c_long/Id.__c_ulong. This should be extended to size_t parameters in extern(C++) functions. We might also consider to change the size_t declaration to exactly match the C++ definition of the used platform.
Comment 1 Martin Nowak 2016-07-18 13:50:33 UTC
It's possible to use cpp_ulong which get's the correct mangling, but it's fairly unfriendly to use.
https://github.com/dlang/druntime/blob/fb0dafb741d33ae030c2e7a96bee2c61aa4d3cb4/src/core/stdc/config.d#L91
Comment 2 Walter Bright 2017-11-01 08:38:24 UTC
Sometimes I just make the C++ function `extern "C"` and that works.
Comment 3 Mathias LANG 2020-02-21 02:17:22 UTC
This has been fixed: https://github.com/dlang/druntime/pull/2160#issuecomment-379976466