www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Interfacing with Rust

https://forum.dlang.org/post/dudpbkerfrdlnggizmpq forum.dlang.org

On Saturday, 1 October 2022 at 03:14:44 UTC, mw wrote:
 extern(C++)?

 Why do you think Rust export C++ linkage?
Rust support [two mangling version](https://doc.rust-lang.org/rustc/symbol-mangling/index.html#mangling-versions) : `legacy` (C++ compatible) and `v0` (theoretical equivalent to `extern(D)`). Until the 2021 edition, legacy is still the default.
 Do it in plain C style, you may make it work.
C ABI is more practical and stable. However, there are cases where adapting to the C style can be limiting compared to C++/D/Rust using more advanced features, including generic programming. An example of this is the use of cbindgen which mixes C with `cpp_compat`.
Oct 04