in my function I allocate memory for and fill a structure called messagePacket
struct messagePacket *packet = malloc(sizeof(struct messagePacket));
//fill
When I try to cast the pointer as a (uint8_t *), gcc throws a warning that says: large integer implicitly truncated to unsigned type
sendBuf(..., (uint8_t *)packet);
I’ve been able to do the following just fine, and I understand I can use this approach as a workaround. I’m here because I would rather learn from this than work around it.
uint8_t *buf = malloc(sizeof(struct messagePacket));
The size of struct messagePacket = 1209 B. My best guess is that the chunk of memory is super large that I gets stored in a high memory address, such as a 16 bye address? But that doesn’t fit with the fact that I can malloc a uint8_t * of the same size.
I think the warning is about some other argument. Please provide the full code for that line, the prototype for the
sendBuf()function, and the full compiler warning for the line in question.As a general idea, the
sendBuf()function should probably use aconst void *rather than aconst uint8_t *for the data to send. Seesend()and friends.