如果架构是 32 位或 64 位,如何检查 Rust? [英] How to check in Rust if architecture is 32 or 64 bit?
本文介绍了如果架构是 32 位或 64 位,如何检查 Rust?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有条件检查处理器是 32 位还是 64 位?我正在寻找一种配置检查,例如#cfg[x86]
或 cfg[x64]
.
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]
.
推荐答案
#[cfg(target_pointer_width = "64")]
来自 cfg 部分在 Rust 参考 似乎是一个可能的解决方案.它基于指针的大小(以及 isize
和 usize
),应该与架构相对应.
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.
这篇关于如果架构是 32 位或 64 位,如何检查 Rust?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文