otisonoza
otisonoza

Reputation: 1344

Cl has no member vector

I'm trying to write a Hello World application using the AMD implementation of OpenCL. http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/introductory-tutorial-to-opencl/

I've setup the directory, lib, etc. as here

The following compiles:

#include "stdafx.h"
#include <CL/cl.h>

int _tmain(int argc, _TCHAR* argv[])
{
    cl_platform_id test;
    cl_uint num;
    cl_uint ok = 1;
    clGetPlatformIDs(ok, &test, &num);

    return 0;

}

However,

#include "stdafx.h"

#include <utility>
#include <CL/cl.hpp>


int _tmain(int argc, _TCHAR* argv[])
{
    cl::vector< cl::Platform > platformList;

    return 0;
}

does not.

I get the following errors:

Error   1   error C2039: 'vector' : is not a member of 'cl' D:\Documents\Projects\Visual Studio\C++\cl_helloworld\cl_helloworld\cl_helloworld.cpp   12  1   cl_helloworld
Error   2   error C2065: 'vector' : undeclared identifier   D:\Documents\Projects\Visual Studio\C++\cl_helloworld\cl_helloworld\cl_helloworld.cpp   12  1   cl_helloworld
Error   3   error C2275: 'cl::Platform' : illegal use of this type as an expression D:\Documents\Projects\Visual Studio\C++\cl_helloworld\cl_helloworld\cl_helloworld.cpp   12  1   cl_helloworld
Error   4   error C2065: 'platformList' : undeclared identifier D:\Documents\Projects\Visual Studio\C++\cl_helloworld\cl_helloworld\cl_helloworld.cpp   12  1   cl_helloworld

IntelliSense underlines vector< cl::Platform > platformList, and when i type cl:: I cannot see a vector class.

EDIT

If I manually copy the content of the cl.hpp to the main.cpp, I see vector in IntelliSense, but still cannot compile the project.

Upvotes: 3

Views: 2584

Answers (1)

DarkZeros
DarkZeros

Reputation: 8410

Use std::vector<cl:XXXX> instead. That is what I use, no problem at all atm, and I have very complex OpenCL C++ apps.

You can also enable the internal cl::vector class by defining before the #include <cl.hpp> #define __NO_STD_VECTOR. But I don't recomend it, since the functionality is poorer than std.

Example: If you have a vector of events, in std you can remove the events selectively. But in cl::vector you have to do it manually.

Upvotes: 6

Related Questions