作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Clang 决定给我一个错误。它决定对我使用 __rdtscp 大喊大叫(这不是我的代码,我不知道那是什么)
error: use of undeclared identifier '__rdtscp'
i2 = __rdtscp(&ui2);
^
error: use of undeclared identifier '__rdtscp'
i3 = __rdtscp(&ui3);
^
error: use of undeclared identifier '__rdtscp'
i2 = __rdtscp(&ui2);
^
error: use of undeclared identifier '__rdtscp'
i3 = __rdtscp(&ui3);
^
error: use of undeclared identifier '__rdtscp'
i2 = __rdtscp(&ui2);
^
error: use of undeclared identifier '__rdtscp'
i3 = __rdtscp(&ui3);
我真的很想弄清楚为什么 Clang 不喜欢我。有谁知道 __rdtscp 是什么以及如何让 clang 冷静下来?
最佳答案
假设您正在为 x86 编译,有一个 __rdtscp
内置函数。如果您正在为其他处理架构编译,它将不可用,因为 rdtscp
基本上是 x86 指令的名称。
这段代码适用于我,从昨天开始使用 clang++ 3.5.0:
#include <iostream>
#include <x86intrin.h>
int main()
{
unsigned int dummy;
unsigned long long t1 = __rdtscp(&dummy);
std::cout << "Hello" << std::endl;
unsigned long long t2 = __rdtscp(&dummy);
std::cout << "Time: " << t2 - t1 << std::endl;
}
您需要包含 x86intrin.h
以将 __rdtscp
转换为编译器知道的实际 __builtin_ia32_rdtscp
函数。
关于c++ - clang 和 __rdtscp : What is it and what is the error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23437796/
Clang 决定给我一个错误。它决定对我使用 __rdtscp 大喊大叫(这不是我的代码,我不知道那是什么) error: use of undeclared identifier '__rdtsc
我正在尝试使用 __rdtscp 内部函数来测量时间间隔。目标平台是 Linux x64,CPU Intel Xeon X5550。尽管为该处理器设置了 constant_tsc 标志,但校准 __r
我想在我的代码中插入一些时间测量。在 x64 上我使用 __rdtscp。 mac m1/m2 有类似的东西吗?具体来说,不是系统调用和高分辨率。 最佳答案 只需使用clock_gettime(CLO
我是一名优秀的程序员,十分优秀!