title: Passing array to function parameter in OpenCL
body: <p>How do I pass array into a function in OpenCL? I got error "..argument of type "_global float *" is incompatible with parameter of type "float *" in line <em>c[n]=FindIndexFromArray(a,3)</em>;</p>
  
  <pre><code>float FindIndexFromArray(float myArray[], float Key)
  {
      // simple looping to find the index
      for (int i=0;i&lt;sizeof(myArray);i++)
         if (myArray[i]==Key)
           return i; 
  
  }
  
  kernel void ProcessArray(
      global read_only float* myArray,
      global read_only float* Key,
      global write_only float* c )
  {
      int index = get_global_id(0); 
      c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter?
  }
  </code></pre>
  
  <p>My edited source code:</p>
  
  <pre><code>float FindIndexFromArray(__global read_only float* myArray[], __global read_only float* Key)
  {
      // simple looping to find the index
      for (int i=0;i&lt;sizeof(myArray);i++)
         if (myArray[i]==Key)
           return i; 
  
  }
  
  kernel void ProcessArray(
      __global read_only float* myArray,
      __global read_only float* Key,
      __global write_only float* c )
  {
      int index = get_global_id(0);
      c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter?
  }
  </code></pre>