Khronos Public Bugzilla
Bug 413 - cl_float4 VS; VS.x=1.0f; //error in MS Visual Studio
cl_float4 VS; VS.x=1.0f; //error in MS Visual Studio
Status: NEW
Product: OpenCL
Classification: Unclassified
Component: Header Files
1.1
PC Windows
: P3 blocker
: ---
Assigned To: Aaftab Munshi
OpenCL Working Group
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-16 19:30 PST by Andrey
Modified: 2013-12-21 01:47 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey 2011-01-16 19:30:59 PST
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;
Comment 1 Ian Ollmann 2011-01-17 13:18:08 PST
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.
Comment 2 Sebastian Schuberth 2011-01-17 14:40:09 PST
(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;