本文介绍了在VisualStudio 2010 Express上的RDTSC - C ++不支持default-int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在VisualStudio 2010上测试 rdtsc 。我的代码:

I tried to test rdtsc on VisualStudio 2010. Heres my code:

#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

What should I do? I dont want to change uint64_t into DWORD64. Why VisualStudio doesnt understand uint64_t?

推荐答案

$ c> #include< stdint.h> 。或者(更好) #include< cstdint>

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

Visual Studio已开始使用2010版本提供这些标头。

Visual Studio started shipping those headers with the 2010 version.

这篇关于在VisualStudio 2010 Express上的RDTSC - C ++不支持default-int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 09:59