RDTSC on VisualStudio 2010 Express - C++ does not support default-int

孤街醉人 提交于 2019-11-29 15:54:21

You have to #include <stdint.h>. Or (better) #include <cstdint>.

Visual Studio started shipping those headers with the 2010 version.

To have this working you have to include cstdint :

#include <cstdint> // Or <stdint.h>

cstdint is the C++-style version of the C-style header stdint.h. Then it is better in your case to use the first one even if both are working in C++.

It is said here that those headers are shipped with visual studio since the 2010 version.

You have not included stdint.h/cstdint at the top apparently. This will work:

#include <iostream>
#include <windows.h>
#include <intrin.h>
#include <stdint.h>
using namespace std;

uint64_t rdtsc()
{
    return __rdtsc();
}

int main()
{
    cout << rdtsc() << "\n";
    cin.get();
    return 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!