I have a function uint8_t EE_Write(uint8_t addr, uint8_t len, uint8_t * buf)
that takes a pointer to some data that it will write to memory, and a uint16_t myword
that I want to give it. The basic
EE_Write(0,sizeof(myword),&myword);
gives me the compiler warning "Indirection to different types ('unsigned int *const ' instead of 'unsigned char *const ')" Even when I typecast the word (int) to a byte (char), I received the exact same warning (and no amount of grouping with parenthesis helped).
EE_Write(0,sizeof(myword),&(uint8_t)myword);
Warnings go away with a union, but it's asinine to have to write it to another variable just to make the compiler happy.
union catbyte {
uint16_t w;
uint8_t b[2];
};
union catbyte mybytes;
mybytes.w = myword;
EE_Write(0,sizeof(myword),mybytes.b);