Struct pointer cast as uint8_t * throws an error

in my function, I allocate memory and populate a structure called messagePacket

struct messagePacket *packet = malloc(sizeof(struct messagePacket));
//fill

When I try to direct the pointer as (uint8_t *), gcc issues a warning saying: the large integer is implicitly truncated to an unsigned type

sendBuf(..., (uint8_t *)packet);

I was able to do the following just fine, and I understand that I can use this approach as a workaround. I am here because I would rather learn from this, besides working around him.

uint8_t *buf = malloc(sizeof(struct messagePacket));

The size of the struct messagePacket = 1209 B. My best guess is that the chunk of memory is super-large, which I store in a high memory address such as the 16th address? But this does not correspond to the fact that I can malloc uint8_t * of the same size.

+3
source
2

, . , , sendBuf() .

, sendBuf() , , const void *, const uint8_t * . . send() .

0

, , 8 uint8_t . , -, , (void *), (uint8_t *). sendBuf , sizeof(struct messagePacket).

+2

All Articles