我尝试rdtsc
在 VisualStudio 2010 上进行测试。这是我的代码:
#include <iostream>
#include <windows.h>
#include <intrin.h>
using namespace std;
uint64_t rdtsc()
{
return __rdtsc();
}
int main()
{
cout << rdtsc() << "\n";
cin.get();
return 0;
}
但我得到了错误:
------ Build started: Project: test_rdtsc, Configuration: Debug Win32 ------
main.cpp
c:\documents and settings\student\desktop\test_rdtsc\test_rdtsc\main.cpp(12): error C2146: syntax error : missing ';' before identifier 'rdtsc'
c:\documents and settings\student\desktop\test_rdtsc\test_rdtsc\main.cpp(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\student\desktop\test_rdtsc\test_rdtsc\main.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\student\desktop\test_rdtsc\test_rdtsc\main.cpp(14): warning C4244: 'return' : conversion from 'DWORD64' to 'int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我应该怎么办?我不想uint64_t
变成DWORD64
. 为什么 VisualStudio 不明白uint64_t
?