I have the following structure and "getter" function that returns a
cast to an unsigned integer:
struct s {
uint32_t a;
};
void get_a(struct s *st, unsigned *ret)
{
*ret = (unsigned)st->a;
}
The following code is run:
struct s st;
uint16_t x;
st.a = 1;
get_a(&st, (unsigned *)&x);
And for x86_64, i686, armv7hl, ppc64le and other architectures x == 1
, but for ppc64 x == 0
. Why is this? Little- vs. big-endian?