How to check in Rust if architecture is 32 or 64 bit?

The #[cfg(target_pointer_width = "64")] from the cfg section in the Rust reference seems like a likely solution. It is based on the size of a pointer (as well as isize and usize), which should correspond to the architecture.

Leave a Comment