What is the advantage of using zero-length arrays in C?
Eg:
struct email { time_t send_date; int flags; int length; char body[]; }list[0]; An array of size 0 is not valid in C.
char bla[0]; // invalid C code From the Standard:
(C99, 6.7.5.2p1) "If the expression is a constant expression, it shall have a value greater than zero."
So list declaration is not valid in your program.
An array with an incomplete type as the last member of a structure is a flexible array member.
struct email { time_t send_date; int flags; int length; char body[]; }; Here body is a flexible array member.
struct {unsigned char a; unsigned char NumAsBytes[0]; unsigned int num;} might not completely overlay NumAsBytes on num; to make it work properly, one would have to add an int dummy[0] before the NumAsByte[0] declaration to force the start of the array to be word aligned.Here is your answer: http://www.quora.com/C-programming-language/What-is-the-advantage-of-using-zero-length-arrays-in-C
disadvantageof using Zero Length arrays.