This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
C and zero-sized arrays - what is the standard?
- From: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 18 Sep 2003 13:52:27 +0200
- Subject: C and zero-sized arrays - what is the standard?
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.