title: Variably modified array at file scope
body: <p>I want to create a constant static array to be used throughout my Objective-C implementation file similar to something like this at the top level of my ".m" file:</p>
  
  <pre><code>static const int NUM_TYPES = 4;
  static int types[NUM_TYPES] = { 
    1,
    2, 
    3, 
    4 };
  </code></pre>
  
  <p>I plan on using <code>NUM_TYPES</code> later on in the file so I wanted to put it in a variable.</p>
  
  <p>However, when I do this, I get the error</p>
  
  <blockquote>
    <p>"Variably modified 'types' at file scope"</p>
  </blockquote>
  
  <p>I gather that this may have something to do with the array size being a variable (I don't get this message when I put an integer literal there, like <code>static int types[4]</code>).</p>
  
  <p>I want to fix this, but maybe I am going about it all wrong...I have 2 goals here:</p>
  
  <ol>
  <li>To have an array which is accessible throughout the file</li>
  <li>To encapsulate <code>NUM_TYPES</code> into a variable so I don't have the same literal scattered about different places in my file</li>
  </ol>
  
  <p>Any suggestions?</p>
  
  <p>[EDIT]
  Found this in the C Faq: <a href="http://c-faq.com/ansi/constasconst.html" rel="noreferrer">http://c-faq.com/ansi/constasconst.html</a></p>