If there a conditional check for whether processor is 32-bit or 64-bit? I'm looking for kind of configuration check like e.g. #cfg[x86]
or cfg[x64]
.
It's both. Once you install rustup , you can switch between 32 and 64 bit with rustup defaut … and platform from this list, such as i686-pc-windows-msvc or x86_64-pc-windows-msvc (or equivalent for Linux, Mac, etc.
x86 is the name of the architecture that it's built to run on (the name comes from a series of old Intel processors, the names of which all ended in 86, The first of which was the 8086). Although x86 was originally a 16-bit architecture, the version in use today is the 32-bit extension.
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.
You should check the Rust Reference chapter on conditional compilation:
target_arch = "..."
- Target CPU architecture, such as"x86"
,"x86_64"
,"mips"
,"powerpc"
,"powerpc64"
,"arm"
, or"aarch64"
. This value is closely related to the first element of the platform target triple, though it is not identical.
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