3 ms·
How does Rust interoperate with C++? For example, would it be easy to integrate V8 into a Rust project?
by amelius 11y ago
How does Rust interoperate with C++? For example, would it be easy to integrate V8 into a Rust project?
- gbersac 11y agoIt doesn't. C++ is too complex. Rust interoperate with c only.
- mseri 11y agoWith specific C++ features there is still a lot of work to do, however the C FFI is solid and simple to use if that is enough for you (see e.g. https://doc.rust-lang.org/book/ffi.html https://doc.rust-lang.org/book/ffi.html). Interfacing Rust and python, ruby, node can be quite simple in fact (micro demo for node: http://calculist.org/blog/2015/12/23/neon-node-rust/ http://calculist.org/blog/2015/12/23/neon-node-rust/)
- rkangel 11y agoNot well. Interoperating with C++ is extremely difficult as the calling conventions are complicated. See this from the "D" documentation: "Being 100% compatible with C++ means more or less adding a fully functional C++ compiler front end" https://dlang.org/spec/cpp_interface.html https://dlang.org/spec/cpp_interface.html
- vardump 11y agoWhen it comes to shared objects (.so, dll, dylib, etc.) not even C++ interoperates with C++, when two different compilers are involved. Name mangling is not standardized, so everyone does their own thing. This breaks binary compatibility.
- Manishearth 11y agoAside from the other comments, https://github.com/michaelwu/rust-bindgen/tree/sm-hacks https://github.com/michaelwu/rust-bindgen/tree/sm-hacks somewhat works for binding to more complicated C++ code. C code, works fine, as always.