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

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -