2 ms·
How stable and usable is Rust's ABI? Can I easily call Rust code from C or other languages that can easily call C functions? I ask because I think this is one a
by cageface 12y ago
How stable and usable is Rust's ABI? Can I easily call Rust code from C or other languages that can easily call C functions? I ask because I think this is one area in which C++ has really failed. C++ is a bad language for building frameworks and libraries for consumption from other languages because interfacing with C++ code is such a nightmare. I'd hope any language that aspires to displace C++ has a better story here.
- dbaupp 12y agoRust's internal ABI (i.e. used for a default `fn foo() { ... }`) is not at all stable/usable/specified. However, you can easily define a function with a C ABI (and a non-mangled symbol name): #[no_mangle] pub extern "C" fn foo() { ... } I'm not sure if you regard this as better than C++'s situation.
- reubenmorais 12y agoYou might be interested in the Portable C++ ABI proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4028.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n402... Considering how quickly C++ compilers are iterating, it might even be available in GCC/Clang before Rust 1.0.