Hi,
Looking to see if the following construct is valid:
typedef struct {
int foo;
char bar[0];
} foobar;
Basically, the idea is to have the structure above point to a message
buffer that has a 4-byte integer followed by a stream of variable
number of bytes. The structure member "bar" is used to reference the
stream of bytes. The above code compiles fine with a GNU based PPC
cross-compiler running on Solaris and seems to do the function
intended.
My question is: Is it legal to declare an array with zero length? Or
should bar have been declared to be at least one element in length?
Comments appreciated.
RS
Looking to see if the following construct is valid:
typedef struct {
int foo;
char bar[0];
} foobar;
Basically, the idea is to have the structure above point to a message
buffer that has a 4-byte integer followed by a stream of variable
number of bytes. The structure member "bar" is used to reference the
stream of bytes. The above code compiles fine with a GNU based PPC
cross-compiler running on Solaris and seems to do the function
intended.
My question is: Is it legal to declare an array with zero length? Or
should bar have been declared to be at least one element in length?
Comments appreciated.
RS
Comment