Bugzilla – Bug 413
cl_float4 VS; VS.x=1.0f; //error in MS Visual Studio
Last modified: 2012-09-28 17:26:25 PDT
cl_float4 VS; VS.x=1.0f; it gives an error C2039: 'x' : is not a member of 'cl_float4' in MS Visual Studio 2005 or 2008 under MS Windows xp sp3 and 7 pro. also I get errors in case VS.s1=1.0f; Also other vector type has the same errors. I see the problem 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;
Does visual studio support anonymous structs in unions? If not, there is nothing we can do here. You'll need to use the .s[index] accessor.
(In reply to comment #1) > Does visual studio support anonymous structs in unions? Yes, it does. Tested with VS2005 and union { struct { float x,y,z; }; struct { float r,b,a; }; } test;