Question

I'm trying to write a code in C++-AMP to copy multiple 2D vectors into GPU memory to be processed. However, once I start with the expression extent<2> eM(100,100); I face this error : "extent" is ambiguous. Is there any conflict with any other extent expression in C++ ? is it because of the libraries I use ? These are all libraries and namespaces I've included, I can't include the code it's pretty long and would be confusing.

#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;
Was it helpful?

Solution

The message means that the compiler can't tell if you want std::extent or concurrency::extent. There are three ways to fix this:

  • remove the #include that brought in std::extent - this is unlikely to be a good solution, since you presumably need something from that header
  • call concurrency::extent by its full name whenever you use it - awkward, but will work
  • remove using namespace std; and replace it with individual statements like using std::endl; as you see among your #include statements.

I like that last one best, though it's more work. The best way to discover which of these you need is to remove the using namespace std; and compile. The error messages will let you know which types from std you are using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top