c++ Initializing a struct with an array as a member
- by Drew Shafer
I've got the following reduced testcase:
typedef struct TestStruct
{
int length;
int values[];
};
TestStruct t = {3, {0, 1, 2}};
This works with Visual C++, but doesn't compile with g++ under linux. Can anyone help me make this specific kind of initializer portable?
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.
Any help much appreciated. Thanks!