title: Initializing all elements of a global array to the same non-zero value
body: <p>I am trying to find a way to initialize all the elements of a global array of unknown fixed size to a non-zero value (0xffffffff).</p>
  
  <p>If <em>array</em> were of fixed known size, this would not be problem, as I could brute force the initialization of each element to 0xffffffff as with the following:</p>
  
  <pre><code>static unsigned int array [4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
  </code></pre>
  
  <p>Unfortunately, I am dealing with an array of unknown fixed size.  In the example below, <strong>SOME_CFG_OPTION</strong> is defined at build time.</p>
  
  <pre><code>#define ARRAY_SIZE   ROUND_UP(SOME_CFG_OPTION);
  
  static unsigned int array [ARRAY_SIZE];  /* array in BSS and elements init'd to 0 */
  </code></pre>
  
  <p>One obvious answer is to initialize <em>array</em> in a constructor or a function that is called very early.  In our setup, this is not an option as it has too high an impact on our boot time.</p>
  
  <p>The following worked well for us when we build with either the GNU or Intel C compilers.</p>
  
  <pre><code>#define ARRAY_SIZE   ROUND_UP(SOME_CFG_OPTION);
  
  static unsigned int array [ARRAY_SIZE]
                      = { [0 ... (ARRAY_SIZE- 1)] = 0xffffffff };
  </code></pre>
  
  <p>However, when we try this with the DIAB C compiler (which we must also support), it barfs on that approach, with the following error </p>
  
  <pre><code>line #: error (etoa:4029): expected an expression
              = { [0 ... (ARRAY_SIZE - 1)] = 0xffffffff };
                     ^
  </code></pre>
  
  <p>Any suggestions on how to solve this when compiling with the DIAB C Compiler?</p>