Hi,
I have a compilation error :
"expression must have arithmetic, enum, or pointer type"
if (Li != (clSpectrum)(0.f))
^
But I don't know why ! The OpenCL spec tell that we can do this... even that we can do "Li != 0.f" !
Please, can you advice ?
float3 Li = ... if (Li != (float3)(0.f))
clSpectrum isn't typedefed to a float3 or scalar, I imagine? It's a struct of some sort?
I would guess that the problem is that OpenCL doesn't define comparison on arbitrary structs. float3 has the comparison operators overloaded on it, and unfortunately as OpenCL C has pretensions of being C rather than C++ you cannot overload other operators on structures.
That's my guess. I've never actually checked to see if struct comparisons work, though.
I tried the following kernel:
__kernel void test(global float *A, global float *B) {
int pos = get_global_id(0);
float4 LI = {0.1f,0.4f,87.87f,0.0f};
float4 LI1 = {0.0f,0.4f,0.8f,0.0f};
if(LI != LI1)
{
}
}
and got the same error.
Thanks for repeating the issue. It has been reported to concerned people.
Okay. ITs nothing wrong with the implementation. actually you cannot put vectors directly in a if condition. The above comparison will result a vector but if takes a scalar. Do this instead and it works
if(all(L1 != L))
{}
Oups, sorry, I just have this
#define clSpectrum float3
So, it is a float3 and not a custom typedef !
What I want is to do this :
if (Li.x != 0 || Li.y != 0 || Li.z != 0) ...
why I cannot write this as if (Li != 0) ??? The specification tell that we can do this !!!
Li != 0 is valid. But it appears to be returning a vector type which "if" cannot handle.
Hi,
I also got the same error while compiling following code:
uint8 i = 0;
for(i = 0; i < 8; i++)
{
//body of loop
}
/tmp/OCLdm84ZS.cl", line 623: error: expression must have arithmetic, enum,
or pointer type
for(i = 0; i < 8; i++)
I fixed the error by changing uint8 to int. The reason i understood as explained by "Lee Howes" is that OpenCL does not define comparision on arbitrary structure. Correct me if I understood wrong !!!