title: how to pass user-defined fixed length array type without warning ( C and OpenCL )
body: <p>I have a few reasons to define a type for a fixed length array such as this:</p>
  
  <pre><code>typedef float fixed_array_t[NX][NY];
  </code></pre>
  
  <p>I then want to pass references to <code>fixed_array_t</code> instances around to other functions.  I'm getting a compiler warning from both GCC and CLANG though I'm seeing correct behavior.</p>
  
  <p>What is this compiler warning telling me and how should my code be modified to avoid the warning?  Bonus, why do I have to <code>#define</code> the array size?  Compile-time constants apparently don't work.  <code>error: variably modified ‘fixed_array_t’ at file scope</code></p>
  
  <p>Here is a small demonstration code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define NX 2  // also, why does const int NX = 2; not work?
  #define NY 3
  typedef float fixed_array_t[NX][NY];
  
  void array_printer( const fixed_array_t arr )
  {
      int i, j;
      for (i = 0; i &lt; NX; i++ )
          for( j=0; j &lt; NY; j++ )
              printf("Element [%d,%d]=%f\n", i,j, arr[i][j] );
  }
  
  int main( int argc, char ** argv )
  {
      fixed_array_t testArray = { {1,2,3}, {4,5,6} };
      array_printer( testArray );
  }
  </code></pre>
  
  <p>GCC warning:</p>
  
  <pre><code>warning: passing argument 1 of ‘array_printer’ from incompatible pointer type
  </code></pre>
  
  <p>CLANG warning (actually compiling equivalent code in OpenCL):</p>
  
  <pre><code>warning: incompatible pointer types passing 'fixed_array_t' (aka 'real [2][3]'), expected 'real const (*)[3]'
  </code></pre>
  
  <p>Yet program operation is fine:</p>
  
  <pre><code>Element [0,0]=1.000000
  Element [0,1]=2.000000
  Element [0,2]=3.000000
  Element [1,0]=4.000000
  Element [1,1]=5.000000
  Element [1,2]=6.000000
  </code></pre>