Following example:
void foo(void)
{
uint8* ptr_data8;
uint32* ptr_data32;
uint32 data32 = 255;
ptr_data32 = &data32;
ptr_data8 = (uint8*)ptr_data32;
}
So depending on the Endianess the memory may look different:
Little-Endian:
Address: [ 0| 1| 2| 3]
-------------------
Value: [255| 0| 0| 0]
Big-Endian:
Address: [ 0| 1| 2| 3]
-------------------
Value: [ 0| 0| 0| 255]
So the question is, to which address do the pointers point to for each architecture?
Do the pointers point to the lowest address of the whole data element?
[Little Endian]
ptr_data8 --> 0
ptr_data32 --> 0
[Big Endian]
ptr_data8 --> 0
ptr_data32 --> 0
Or do they point to the lowest value/byte of the data element?
[Little Endian]
ptr_data8 --> 0
ptr_data32 --> 0
[Big Endian]
ptr_data8 --> 0
ptr_data32 --> 3
Also, is the address where the pointers point to platform/compiler/architecture dependent and is there a definition for this behaviour somewhere?