I don't know why this was voted down, it's a good question that exposes a confusing behaviour of C.
The confusion comes because normally when you define an array a real pointer is created:
char data[100];
printf("%p\n", data); // print a pointer to the first element of data[]
printf("%p\n", &data); // print a pointer to a pointer to the first element of data[]
So on a typical 32 bit desktop system 4 bytes are allocated for data
, which is a pointer to 100 chars. Data
, the pointer, itself exists somewhere in memory.
When you create an array in a struct no pointer is allocated. Instead the compiler converts references to packet.data
into a pointer at runtime but does not allocate any memory for storing it. Rather it just uses &packet + offsetof(data)
.
Personally I would prefer the syntax to be consistent and require an ampersand, with packet.data generating some kind of compile time error.