本文介绍了我如何调用“cpuid"?在 Linux 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
在为 Windows 编写新代码时,我偶然发现了 Windows API 中的 _cpuinfo()
.由于我主要处理 Linux 环境 (GCC),因此我想访问 CPUInfo.
While writing new code for Windows, I stumbled upon _cpuinfo()
from the Windows API. As I am mainly dealing with a Linux environment (GCC) I want to have access to the CPUInfo.
我尝试了以下方法:
这个使用程序集,但我不想重新发明轮子.有没有其他方法可以在没有汇编的情况下实现 CPUInfo?
This use assembly but I don't want to re-invent the wheel. Is there any other way to implement CPUInfo without assembly?
编译器错误:
推荐答案
既然你是用 GCC 编译的,那么你可以包含声明这些函数的 cpuid.h
:
Since you are compiling with GCC then you can include cpuid.h
which declares these functions:
您不需要也不应该重新实现此功能.
You don't need to, and should not, re-implement this functionality.
这篇关于我如何调用“cpuid"?在 Linux 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!