Kasun
Kasun

Reputation: 307

OpenCL Compiler Error C4996

I am new to 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

thanks.

Upvotes: 1

Views: 1863

Answers (1)

Anteru
Anteru

Reputation: 19434

It's pretty simple: The cl namespace provides a vector class, which you're picking up due to your use of 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>. std::vector does everything needed; 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.)

You shouldn't be using the std namespace either. Notice that once you use both cl and the std namespace, your code will fail as there will be suddenly two vector classes colliding. So just say no!

Upvotes: 6

Related Questions