by pcwalton · 10y ago · 0 comments
Not compiling to C is a feature. It insulates us from the undefined behavior of C (signed overflow never results in UB in Rust, for example) and allows us to actually get proper debug info.
Furthermore, if your frontend doesn't know about structure layout then you forgo some important systems language features. For example, you can't implement sizeof as a compile time constant.
Sure and you only need to call libclang for each different platform. Or is it on every platform? ;-)
(I agree that it's a tradeoff generally, I'm just not sure this example is particularly motivating.)
No, because the interface is
int stat(const char *path, struct stat *buf);?
(Which is how stuff like https://docs.rs/libc/0.2.16/libc/fn.stat.html is built)