I am when I am building a struct like this in C :
typedef struct packet {
uint32_t source; // processus source
uint64_t numPacket; // Number of the message. The first message has a value of 1 for this attribute.
uint8_t ack; // is ack or not (0 if not ack)
uint32_t size;
char message[MAX_BUFLEN]; // message (data)
} Packet;
The address of the different fields is not correct. For example, if ptr is pointing on a "Packet" :
ptr is pointing on the address 0x7fff59464720
&(ptr->source) is pointing at the address 0x7fff59464720
&(ptr->numPacket) is pointing at the address 0x7fff59464728
&(ptr->ack) is pointing at the address 0x7fff59464730
&(ptr->size) is pointing at the address 0x7fff59464734
&(ptr->message) is pointing at the address 0x7fff59464738
As you can see, this is not the correct address since the size of the source field is a uint32_t (=4) and not 8, and the size of ack is a uin8_t (=1) and not 4.
I do not know why this behave like this. If you have an idea, thanks for your answer.