I'm trying to typecast the uint8_t
buffer to structure
with bit
field as below.
#include<stdio.h>
#include<inttypes.h>
struct msg{
uint64_t field:56;
};
void main()
{
uint8_t buf[8]={0x7,0x6,0x5,0x4,0x3,0x2,0x1};
struct msg *m = buf;
printf("buf=%"PRIx64"\n",m->field);
}
But I'm getting the output as below.
Actual output:
buf=1020304050607
Expected output:
buf=7060504030201
Am I doing anything wrong while typecasting?