Results 1 to 5 of 5

Thread: Compile error for float4 array

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    11

    Compile error for float4 array

    Hi there,

    I am trying to initialize the following array:

    __constant float4 splitter_cache[2] like this:

    __constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };

    But I get a compile error. What's the problem?
    Code :
    clBuildProgram() failed: -11
    <:5: error: incompatible type initializing 'float4', expected 'float'
    __constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    :5: error: incompatible type initializing 'float4', expected 'float'
    __constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };
                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

  2. #2
    Member
    Join Date
    Nov 2009
    Location
    Scotland
    Posts
    72

    Re: Compile error for float4 array

    Try this:
    Code :
    __constant float4 splitter_cache[2] = { 0.0f, 0.0f };
    I think float gets promoted to float4 in this assignment, i.e. all components of float4 will be initialized to 0. Haven't tried it though.

  3. #3
    Member
    Join Date
    Oct 2010
    Location
    Vancouver, Canada
    Posts
    66

    Re: Compile error for float4 array

    It compiles fine on the implementation I have available. You might want to report that as a bug to your implementation vendor(s). Do you still get an error if you just mark it const so that it is instead in private memory?

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    11

    Re: Compile error for float4 array

    Quote Originally Posted by andrew.brownsword
    Do you still get an error if you just mark it const so that it is instead in private memory?
    Yes, same error.

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    27

    Re: Compile error for float4 array

    Well, on my system (Mac OS X 10.6.6, ATI HD 5750)

    the following code compiles well in a kernel function.

    Code :
    const float4 kernel_x[3] = {
    			(float4)(-1,0,1,0), 
    			(float4)(-2,0,2,0), 
    			(float4)(-1,0,1,0)
    };

Similar Threads

  1. Error in compile project
    By morteza271 in forum OpenCL
    Replies: 1
    Last Post: 09-19-2012, 06:31 AM
  2. a compile error message from PowerVR SDK
    By wycwang in forum OpenVG and VGU
    Replies: 0
    Last Post: 12-18-2007, 06:06 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
  •