When I have an array in a struct, the meaning is totally clear to me: When the struct is defined, memory for the whole array is reserved and when I copy the struct, all the array contents is copied.
typedef struct {
uint8_t type;
struct {
uint8_t length;
uint8_t data[5];
} m;
} s;
But when I use uint8_t data[], what does that mean? I guessed it might be the same as uint8_t *data but it isn’t. When I try to assign to it like this:
s the_s;
uint8_t something[] = {1, 2, 3};
the_s.m.data = something;
the compiler gives me
cannot assign array type objects
An array of an incomplete type as the last member of a struct is a C99 feature called the flexible array member feature.
In this statement
the_s.m.data = something;you are trying to assign an array but in C, arrays cannot be assigned.