So i’m trying to initialize a variable in my opencl host code like this:
cl_float2 es = (cl_float2)(0.0f,0.0f);
Which, using Clang 2.9, fails with:
source/solveEikonalEq.c:75:38: warning: expression result unused [-Wunused-value]
cl_float2 es = (cl_float2)(0.0f,0.0f);
^~~~
source/solveEikonalEq.c:75:26: error: cast to union type from type 'float' not present in union
cl_float2 es = (cl_float2)(0.0f,0.0f); //ray's tangent vector
^ ~~~~~~~~~~~
And, when using GCC 4.6.1, fails with:
source/solveEikonalEq.c:75:42: warning: left-hand operand of comma expression has no effect [-Wunused-value]
source/solveEikonalEq.c:75:26: error: cast to union type from type not present in union
I’m using AMD’s opencl sdk, and can build the examples just fine.
What is it i’m doing wrong?
You are trying to use an OpenCL C-style initializer in your host code, which is presumably compiled with a C compiler. That style of initialization is only valid in your kernels, in other words. And there, you would not use a platform type, but would instead just use a
float2.Try this in your host code instead:
That will work for you.