I have declared a flexible array member in union, like this:
#include
union ut
{
int i;
int a[]; // flexible array member
};
int m
No, unions do not support flexible array members, only structs. C11 6.7.2.1 §18
As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member.
In addition, zero-length arrays is not valid C, that's a gcc non-standard extension. The reason why you get this to work is because your compiler, gcc, is configured to compile code for the "non-standard GNU language". If you would rather have it compile code for the C programming language, you need to add compiler options -std=c11 -pedantic-errors
.