general recommendation is to start with the biggest variables.
--> first all 32 bit variables then all 16 bit variables, then all 8 bit variables. This is to avoid "align" bytes.
Now it depends
* if you want to copy the struct into an 8 bit array
* or you just want to access the struct data
...( I´m no C specialist, thus - in doubt - rely on the answers of others)
COPY:
needs to be done byte by byte like:
You need to consider that depending on compler settings and processor hardware requirements the structure message_t isn't necessarily respectively even can't be packed. Thus type conversions of the discussed kind aren't safe and not necessarily portable.
Another option may be to use a union that contains both the struct and the array.
All of the usual caveats apply regarding compiler options, alignments, struct padding etc..
Susan