C and zero-sized arrays - what is the standard?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux