Reinterpreting objects that don't have allocated storage duration as objects of some other (incompatible) type is undefined behavior.
In your example Buff
which has type uint8_t
which has either static or automatic storage duration, is being reinterpreted as type DWORD
. Those type are not compatible1, the behavior is not defined.
You should simply define Buff
as type you intend to use, which appears to be DWORD
:
volatile DWORD Buff[READ_BUFF_SIZE];
and then you don't need macros for access, simply using the built-in operator will do:
ChunkID = Buff[0];
1 Even if we assume2 uint8_t is defined as unsigned char, which may alias any type, the type DWORD
may not alias unsigned char
.
2 Standard permits that the type uint8_t
is not defined as unsigned char
even if CHAR_BIT is 8. See extended integer types.