【发布时间】:2021-02-05 04:27:45
【问题描述】:
基本上,我喜欢获取应用运行的 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.
*/
【问题讨论】:
-
我看到的唯一相关的是getting number of threads supported。我想,除此之外的一切都依赖于操作系统,并且需要针对每种情况进行处理。
-
std::hardware_destructive_interference_size&std::hardware_constructive_interference_size也与硬件有关,但我认为 gcc 拒绝实现这些。 -
@user63898 我没有投反对票 - 但仅使用标准 C++ 无法做到这一点。您必须使用操作系统特定的功能。
-
这是用于什么平台的?
-
没有多大意义,不像 Javascript C++ 是一种编译语言。使用特定于 cpu 的机器码作为编译结果。因此,您必须在编译之前选择架构。在运行时,您只会取回您之前已经知道的内容。
标签: c++ cpu-architecture