Check if binary is 64bit or 32bit

hello folk.
I have this code, and run OK, but tried detect if a binary input is of 32 bits or 64bit, Is posible check this whit cfg?. For example using let mut file = File::open("../data/vs_Community.exe").unwrap();?


fn main() {

let machine_kind = if cfg!(unix) {


} else if cfg!(windows) {


} else {



println!("I'm running on a {} machine!", machine_kind);



You can use the target_arch config value to determine what kind of processor your program was compiled for, or target_pointer_width if you just want to know whether it is a 32-bit or 64-bit binary.

For example:

if cfg!(target_pointer_width = "32") {
    println!("32 bits")
} else if cfg!(target_pointer_width = "64") {
    println!("64 bits")
} else {

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.