The code that you have there will work the same. This is because downcasting behavior is defined by the C standard.
However, if you did this:
uint64_t a = 0x0123456789abcdefull;
uint32_t b = *(uint32_t*)&a;
printf("b is %x",b)
Then it will be dependent on the end.
EDIT:
Little Endian: b - 89abcdef
Big Indian: B - 01234567
source
share