I'm aware that the libc crate in Rust contains much of C's standard macros and functions for use in Rust, but it also states that it is not concerned with portability between systems. I'm porting some code that uses C's preprocessor macros extremely heavily from C to Rust, and only includes some code if a given macro is defined: in this case O_BINARY
. Is it possible to check whether the O_BINARY
macro is defined on my system in Rust, and if so, what does this look like?
I'm looking for a construct that can replicate this C syntax rather closely:
#ifdef O_BINARY
// Some extra code here
#endif
// Regular code