title: c++ Initializing a struct with an array as a member
body: <p>Edited again because it originally wasn't clear that I'm trying to initialize the arrays at compile time, not at run time...</p>
  
  <hr>
  
  <p>I've got the following reduced testcase:</p>
  
  <pre><code>typedef struct TestStruct
  {
      int length;
      int values[];
  };
  
  TestStruct t = {3, {0, 1, 2}};
  TestStruct t2 = {4, {0, 1, 2, 3}};
  
  int main()
  {
      return(0);
  }
  </code></pre>
  
  <p>This works with Visual C++, but doesn't compile with g++ under linux.  Can anyone help me make this specific kind of initializer portable?</p>
  
  <p>Additional details: the actual structure I'm working with has several other int values, and the array can range in length from a single entry to over 1800 entries.</p>
  
  <p>EDIT: I think (but am not sure) that this is not a VLA issue.  To clarify, I'm trying to get the compiler to do the work for me at compile-time.  The length of the array at run-time is constant.  Apologies if I'm wrong; I'm primarily a c#/Perl/Ruby programmer who is stuck maintaining this legacy app...</p>
  
  <p>Any help much appreciated.  Thanks!</p>