3 ms·
> If Rust call out to C code and they were using incompatible understanding of an array length due to mismatching build rules (like preprocessor definitions), y
by LegionMammal978 4y ago
> If Rust call out to C code and they were using incompatible understanding of an array length due to mismatching build rules (like preprocessor definitions), you have a soundness bug it won't show up obviously in any interfaces anywhere.
In that scenario, I'd say that the build rules are a poorly-documented part of the C code's interface, and by calling out to it with mismatching build rules the Rust code is unsound.
In general, C interfaces tend to have a lot of poorly-documented or undocumented preconditions, which is one of the things that make Rust-to-C FFI so tricky. One of Rust's big ideas is to make all these preconditions fully explicit, either through typestate or through "Safety" sections on unsafe functions and traits.
- humanrebar 4y agoBad docs and brittle build expectations make C to C "ffi" tricky as well. But it's realistically how this kind of programming, generally speaking, tends to happen. I don't expect we'll have a great end to end solution until there are language agnostic build and dependency management systems available. As much as I like cargo, I don't expect porting everything to cargo will cut it. At least not in its current form.