C and zero-sized arrays - what is the standard?
Alexandre Courbot
Alexandre.Courbot@lifl.fr
Thu Sep 18 11:48:00 GMT 2003
Hi everybody,
Consider the following code:
struct MyStruct
{
int a;
int b[];
};
struct MyStruct i = { 10, {1, 2, 3, 4} };
struct MyStruct j = { 20, {10} };
int main(int argc, char * argv[])
{
return 0;
}
This kind of code is very common in embedded systems programming. The above
code works fine with GCC, but some other compilers require MyStruct to be
declared as
struct MyStruct
{
int a;
int b[0];
};
Is there a portable way to do this? What is the right form according to the
standards?
Thanks,
Alex.
More information about the Gcc-help
mailing list