Results 1 to 3 of 3

Thread: Visual studio problem with cl_vector types

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    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;

  2. #2
    Member
    Join Date
    Mar 2010
    Location
    Raleigh, NC
    Posts
    55

    Re: Visual studio problem with cl_vector types

    I can confirm that the 'shortcuts' don't work.

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

    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).

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    Re: Visual studio problem with cl_vector types

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

Similar Threads

  1. Replies: 4
    Last Post: 04-15-2010, 01:12 PM
  2. Replies: 2
    Last Post: 03-04-2010, 09:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •