The libc library defines a number of constants that can be passed as flags to open() such as O_APPEND, O_CREAT, etc. Some of these flags are only defined for certain OS targets. It'd be nice if there was a way to freely use O_WHATEVER in my code without worrying about whether it was actually defined in libc:
#[cfg(???)]
const O_WHATEVER = libc::O_WHATEVER;
#[cfg(not(???))]
const O_WHATEVER = 0;
It'd be nice if the ??? in my example above was some kind of is_defined(libc::O_WHATEVER). Otherwise, I'd need to figure out all of the OS combinations in which O_WHATEVER is defined in libc and that'd be a real pain.
Not as of Rust 1.41. RFC 2523 — cfg_version and cfg_accessible introduces:
#[cfg(accessible(libc::O_WHATEVER))]
const O_WHATEVER = libc::O_WHATEVER;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With