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]
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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.