9 ms·
I use Rust daily to cobble it together with C object files. rustc --crate-type staticlib file.rs -o rusty.a gcc file.c rusty.a ./a.out It totally
by pornel 9y ago
I use Rust daily to cobble it together with C object files.
rustc --crate-type staticlib file.rs -o rusty.a
gcc file.c rusty.a
./a.out
It totally works (and debug symbols, C debuggers, profilers, code coverage — all works in the mixed executable).
Of course C can't directly call Rust's ABI, but Rust can call and export `extern "C"` functions, and there are tools to automate this. You can declare C function prototypes in Rust using references instead of raw pointers, so you even get basics of borrow checking for the C code.