title: Why can't the size of a static array be made variable?
body: <blockquote>
    <p><strong>Related but not quite duplicate as it discusses C++:</strong><br>
    <a href="https://stackoverflow.com/questions/7696591/can-we-give-size-of-static-array-a-variable">can we give size of static array a variable</a>  </p>
  </blockquote>
  
  
  
  <p>I am defining an array in one of the child files as follows.</p>
  
  <pre><code>static int arr[siz];
  </code></pre>
  
  <p>Here <code>siz</code> is a global variable available to the child file. But the gcc compiler produces the following error :</p>
  
  <pre><code>&lt;filename&gt;: &lt;line_num&gt; : error : storage size of ‘arr’ isn’t constant
  </code></pre>
  
  <p>Why can't I define a <code>static</code> array of variable size ? </p>
  
  <p>EDIT : This seems to be a problem only for <code>static int</code> type. If I change the variable type of <code>arr</code> from <code>static int</code> to <code>int</code>, the error goes away, even though the size of array is still dependent on a variable <code>siz</code>.</p>