简体   繁体   中英

c++ mac/m1/intel how to get cpu architecture?

I need to find out at runtime which architecture the cpu is running. I've so far used qt : QSysInfo::currentCpuArchitecture() but there is a problem. The returned value will change when ever I run application that was compiled for x86_64 or arm64. So this will not return the hardware architecture that the system is natively running, but the emulated one by mac. Say if I run x86_64 it would run via rosetta probably and then the arch would be x86_64 and not arm64.

I need a way to find out hardware arch of system that is, and not is emulated...

Does any1 have any idea how to do it? Macros/etc will not work.

Running QProcess from within the app still returns x86_64 from uname -p etc.

Starting QProcess does not work, he inherits base application architecture.

I found out that apple added a command to figure out if I'm running in "translated" mode, this can then be used as indication if we are on intel or arm.

https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM