title: Using the sizeof operator in the initialization of a struct with a flexible array
body: <p>I want to declare a struct with a flexible array member in it, and then use <code>sizeof()</code> on it. The prototype is:</p>
  
  <pre><code>typedef struct
  {
      uint16_t    length;
      uint8_t     array[][2];
  } FLEXIBLE_t;
  </code></pre>
  
  <p>I then declare it:</p>
  
  <pre><code>const FLEXIBLE_t test = {
      .length = sizeof(test),
      .array = {  {   0,  1   },
                  {   2,  3   },
                  {   4,  5   },
                  {   6,  7   },
                  {   8,  9   } }
  };
  </code></pre>
  
  <p>Everything compiles okay (GCC) but when I examine <code>test.length</code> it has the value 2, i.e. it is only counting the <code>uint16_t</code> for <code>length</code> itself.</p>
  
  <p><strong>How can I calculate the size of the struct at compile time?</strong> It appears that the compiler uses the prototype rather than the specific instance.</p>