c ++ 17如何获得跨平台的CPU架构

问题描述

基本上,我喜欢获取运行应用程序的 cpu 架构的类型 类似于 node.js os.arch()process.arch
它可以是我可以链接到我的应用程序的任何 C++/C 库 但不是 Qt,因为我不能使用它

更新

这是 node.js 中的内容

 function arch(): string;
    /**
     * Returns a string identifying the kernel version.
     * On POSIX systems,the operating system release is determined by calling
     * [uname(3)][]. On Windows,`pRtlGetVersion` is used,and if it is not available,* `GetVersionExW()` will be used. See
     * https://en.wikipedia.org/wiki/Uname#Examples for more information.
     */

解决方法

使用标准 C++ 无法做到这一点。如果您使用 Qt,则 QSysInfo::currentCpuArchitecture() 完全符合您的要求。