c++ - llittle endianness of a structure in a structure -


given hypothetical structure

struct outer {   uint_16 x;   struct inner{      uint_16 y;      uint_16 z;   } inner_struct; } outer_struct; 

and little endian machine, how bytes flipped, i.e. bytes outer_struct like?

suppose x,y,z = ox1234; assume alignment of 2 bytes.

i'm confused between

34 12 34 12 34 12 // x y z

and,

34 12 12 34 12 34 // x flipped-little_endian_inner_struct

the thing little endian flips order of bytes in builtin data types. compiler not free re-order attributes in structure, , endian-ness doesn't apply aggregate data structures (only components). you'll see 34 12 34 12 34 12 result in memory.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -