Re:Nim Programming Language v0.15.0 released
by SamReidHughes on Saturday October 01, 2016 @09:52PM
(#12620744)
> Wouldn't you just use libc directly from Rust if you wanted that?
No, because the interface is
int stat(const char *path, struct stat *buf);
Re:Nim Programming Language v0.15.0 released
by steveklabnik on Saturday October 01, 2016 @10:37PM
(#12620822)
https://docs.rs/libc/0.2.16/libc/fn.stat.html
?
(Which is how stuff like https://docs.rs/libc/0.2.16/libc/fn.stat.html is built)
Re:Nim Programming Language v0.15.0 released
by SamReidHughes on Saturday October 01, 2016 @11:00PM
(#12620870)
It would be physically impossible for a call to that function to work with a single definition of the struct stat, because the set of fields (and their ordering) and struct size differ between platforms. So that libc wrapper must provide separate definitions of the struct for each platform.
Re:Nim Programming Language v0.15.0 released
by steveklabnik on Sunday October 02, 2016 @08:46PM
(#12625010)
Ah, sorry! I was thinking about things like "the size of this type is different per-platform," not "every single platform has a different definition of this struct."
I still think that, given Cargo, the one-time cost makes it worth it, but after seeing my error, think that the point makes more sense. Thank you for being patient. :)
(I agree that it's a tradeoff generally, I'm just not sure this example is particularly motivating.)