Visual studio problem with cl_vector types

I work under Windows XP sp3 and 7 pro under my OpenCL app with VS2005 and VS 2008. In both cases i ve received error when i try to address to .x .y .z components of cl_float4 or cl_float3 types on host side like

cl_float4 VS;
VS.x=1.0f; //error C2039: ‘x’ : is not a member of ‘cl_float4’
or VS.s1=1.0f;
I think problem is in cl_platform.h
typedef union
{
cl_float CL_ALIGNED(16) s[4];
#if defined( GNUC) && ! defined( STRICT_ANSI )
extension struct{ cl_float x, y, z, w; };
extension struct{ cl_float s0, s1, s2, s3; };
extension struct{ cl_float2 lo, hi; };
#endif
#if defined( CL_FLOAT2)
__cl_float2 v2[2];
#endif
#if defined( CL_FLOAT4)
__cl_float4 v4;
#endif
}cl_float4;

I can confirm that the ‘shortcuts’ don’t work.

What has worked for me is to use “.s[]” , so, for example, with your code,


cl_float4 VS;
VS.s[0] = 1.0f;

This has worked for me for my thesis research code. I have not tried to make the cl_platform.h code work for Visual Studio by modifying the cl_float4 structure (though I cannot imagine it being terribly difficult to pull off).

Of course it is workaround, but i have a lot of code written for linux which i hope to compile with MS VS too.