PDA

View Full Version : 'y' is not a member of cl_float2



nachovall
06-01-2011, 04:50 AM
Hi,

I'm having a compiling issue.

cl_float2 p;
p.x = 1.0;
p.y = 1.0;

reports the error:

'x' is not a member of cl_float2
'y' is not a member of cl_float2

The same happens with cl_float4, but

p.s[0]=1.0; and p.s[1]=1.0; works fine.

Looking at cl_platform.h:


typedef union
{
cl_float CL_ALIGNED(8) s[2];
#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
__extension__ struct{ cl_float x, y; };
__extension__ struct{ cl_float s0, s1; };
__extension__ struct{ cl_float lo, hi; };
#endif
#if defined( __CL_FLOAT2__)
__cl_float2 v2;
#endif
}cl_float2;

the extensions are not defined. I mean, __GNUC__ and __STRICT_ANSI__ are not defined so it just define s[2]. Anyone knows how to solve it?

I'm working on windows 7 x64, visual studio 2008, NVIDIA CUDA SDK 3.2. The projects is compiled and linked in win32 not x64.

Any help will be apreciated. Thanks

HolyGeneralK
06-06-2011, 07:01 AM
You're about the 5th or 6th person I've seen with this complaint (I being one of the others). As a workaround (since I know my code is never going to run outside of my machine), I've gotten rid of the if() definitions to make it work on Visual Studio.

nachovall
06-06-2011, 07:09 AM
I've gotten rid of the if() definitions to make it work on Visual Studio.

I finally opt by another solution. I do MakeFile projects with visual studio and I compile with the gcc compiler via cygwin. This way __GNUC__ variable is defined and the compiler launches no error.

Anyway, your solution is faster and easier.