I tried converting something from using struct hack to using a flexible array element, only to execute the following error message:
error: invalid use of structure with flexible array element
(GCC 4.8.1, gnu99, MinGW)
After trying to track down the cause of the message, I redid it into the following relatively minimal case:
struct a { union { struct { int b; int c[]; } d; } e; };
In other words, a structure with a flexible member of an array does not see to be placed inside the union in the structure, even if the union is the last member of the structure.
(Note that including the flex array element directly inside the union does work.)
Now: is there a good way to get around this, besides returning back to the structure hacker (declaring c as an array of length 1)? A pointer to the structure within the union will work, but an extra layer of indirection suffers.
source share