2013-06-18 39 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命名空間時,還有其他類似的衝突;想到數組,範圍和索引。 –