2013-06-18 40 views
3

我试图用C++ -AMP编写代码来将多个2D矢量复制到要处理的GPU内存中。但是,一旦我开始使用表达式extent<2> eM(100,100);,我将面临以下错误:“范围”不明确。与C++中的任何其他程度表达式是否有冲突?是因为我使用的图书馆? 这些都是我包含的所有库和命名空间,我不能包含它相当长的代码,会令人困惑。不明确的陈述C++ - AMP:(范围)不明确

#include "stdafx.h" 
#include <Windows.h> 
#include <stdint.h> 
#include <amp.h> 
#include <Shlwapi.h> 
#include <vector> 
#include <random> 
#include <iostream> 
using std::endl; 
using std::cout; 
#include <iomanip> 
#include "timer.h" 
#include <fstream> 
using std::ifstream; 
#include <cstring> 
#include <sstream> 
#include <tchar.h> 
using namespace std; 
using namespace concurrency; 
using std::vector; 

回答

5

该消息意味着,如果你想std::extentconcurrency::extent编译器不能告诉。有三种方法来解决这个问题:

  • 删除在std::extent带来的#include - 这是不太可能是一个很好的解决方案,因为你可能是通过其全名需要从该头的东西
  • 通话concurrency::extent每当你使用它 - 尴尬,但将工作
  • 删除using namespace std;并将其替换为using std::endl;之类的单个语句,如您在#include语句中看到的那样。

我最喜欢上一个,尽管这是更多的工作。发现你需要的这些的最好方法是删除using namespace std;并编译。错误信息会让你知道你正在使用的std类型。

+2

当使用std和concurrency命名空间时,还有其他类似的冲突;想到数组,范围和索引。 –