i have to read out the bytes of a uint32_t variable, and i have seen this kind of implementation from a colleague of mine. My Question is, if the behaviour of that code-example is reliable on "nearly every" 32bit microcontroller. Does it supposable work on every 32bit Microcontroller or is it platform-specific behaviour i am relying on? P.S.: the endianness of the system shall not be considered in this example.
uint8_t byte0=0;
uint8_t byte1=0;
uint8_t byte2=0;
uint8_t byte3=0;
uint8_t *byte_pointer; //byte_pointer
uint32_t *bridge_pointer;//pointer_bridge between 32bit and 8 bit variable
uint32_t var=0x00010203;
bridge_pointer=&var; //bridge_pointer point to var
byte_pointer=(uint8_t *)(bridge_pointer); //let the byte_pointer point to bridge_pointer
byte0=*(byte_pointer+0); //saves byte 0
byte1=*(byte_pointer+1); //saves byte 1
byte2=*(byte_pointer+2); //saves byte 2
byte3=*(byte_pointer+3); //saves byte 3
Thanks in Advance