rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.06k stars 1.03k forks source link

windows: stat::st_mode and S_IFMT are of different type #3161

Open cgzones opened 1 year ago

cgzones commented 1 year ago

On windows stat::st_mode https://github.com/rust-lang/libc/blob/bac14427831aaff9b79dcdd125c03109414215c5/src/windows/mod.rs#L60 and S_IFMT (and other mode flags) https://github.com/rust-lang/libc/blob/bac14427831aaff9b79dcdd125c03109414215c5/src/windows/mod.rs#L146 are of different type, resulting in code like

fn is_regular(stat: &libc::stat) -> bool {
    stat.st_mode & libc::S_IFMT == libc::S_IFREG
}

to not be portable.

joshtriplett commented 1 year ago

We need to check if these are in fact different types in Windows headers, or if they're the same type and we have an error in the crate's types.

ChrisDenton commented 1 year ago

Here's the ucrt header.