简体   繁体   English

OpenCL编译器错误C4996

[英]OpenCL Compiler Error C4996

I am new to opencl domian. 我是opencl domian的新手。 I have read through some books and try to compile following code 我已经通读了一些书,并尝试编译以下代码

#define __CL_ENABLE_EXCEPTIONS
#define __NO_STD_VECTOR
#define PROGRAM_FILE "blank.cl"
#define KERNEL_FUNC "blank"
//#define __MAX_DEFAULT_VECTOR_SIZE 100

#include <cstdio>
#include <fstream>
#include <iostream>
#include <iterator>

#ifdef Windows
    #include <OpenCL/cl.hpp>
#else
    #include <CL/cl.hpp>
#endif

using namespace std;
using namespace cl;

int main() {
    // int n = 10;    
    vector<Platform> platforms;
    vector<Device> devices;

    try {
    } catch (exception e) {
    }
    return 0;
}

but it gives me many errors. 但这给了我很多错误。

most of them are as following 他们大多数如下

Error   14  error C4996: 'cl::vector<char *,10>': was declared deprecated   C:\Program Files (x86)\AMD APP SDK\2.9\include\CL\cl.hpp    1138    1   Matrix_multilpy_C

So can any one please help me. 所以任何人都可以帮助我。 I am using visual studio 2013 to code and I have find out my version is openCL 1.2 我正在使用Visual Studio 2013进行编码,我发现我的版本是openCL 1.2

thanks. 谢谢。

It's pretty simple: The cl namespace provides a vector class, which you're picking up due to your use of using namespace cl; 很简单: cl命名空间提供了一个vector类,由于使用了using namespace cl; ,因此需要选择它using namespace cl; .

Remove that line, #include <vector> , remove the __NO_STD_VECTOR define and simply use a std::vector<cl::Device> , std::vector<cl::Platform> . 删除该行,包括#include <vector> ,删除__NO_STD_VECTOR定义,只需使用std::vector<cl::Device>std::vector<cl::Platform> std::vector does everything needed; std::vector做所有需要的事情; for some reason or another, the OpenCL headers used to ship with a custom vector class, which should not be used any more (I have no idea why it was added in the first place actually.) 由于某种原因或其他原因,用于自定义矢量类的OpenCL标头通常不应该再使用(我不知道为什么实际上首先添加了它)。

You shouldn't be using the std namespace either. 您也不应该使用std名称空间。 Notice that once you use both cl and the std namespace, your code will fail as there will be suddenly two vector classes colliding. 请注意,一旦同时使用clstd名称空间,您的代码就会失败,因为突然会有两个向量类发生冲突。 So just say no! 所以就说不!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM