Cl没有成员向量

时间:2013-11-08 14:07:24

标签: c++ visual-studio-2012 opencl gpu amd-processor

我正在尝试使用OpenCL的AMD实现编写Hello World应用程序。 http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/introductory-tutorial-to-opencl/

我已经设置了目录,lib等as here

以下编译:

#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;

}

然而,

#include "stdafx.h"

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


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

    return 0;
}

没有。

我收到以下错误:

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强调vector< cl::Platform > platformList,当我输入cl ::时,我看不到矢量类。

修改

如果我手动将cl.hpp的内容复制到main.cpp,我在IntelliSense中看到了vector,但仍然无法编译项目。

1 个答案:

答案 0 :(得分:6)

请改用std::vector<cl:XXXX>。 这就是我使用的,没有任何问题,我有非常复杂的OpenCL C ++应用程序。

您还可以通过在cl::vector #include <cl.hpp>之前定义来启用内部#define __NO_STD_VECTOR课程。但我不推荐它,因为功能比std差。

示例: 的 如果您有事件向量,则可以在std中有选择地删除事件。但是在cl :: vector中你必须手动完成。