I am working on C firmware project. I have a union that is defined as,
typedef union {
unsigned long value;
unsigned char bytes[4];
} LONGVALUE;
I also have a function that has this prototype,
char sendHexToASCII_UART(char *msg, int cnt);
and a variable of type LONGVALUE defined as,
LONGVALUE countAddr;
THE PROBLEM:
I fill the individual bytes of the union variable with values from an array (tempBuff1), I then want to pass the address of the first element in the union to a function that will print it to the UART. On my function call sendHexToASCII_UART((int *)countAddr.bytes[0], 4);
, I get a compiler warning saying "cast to pointer from integer of different size". Can someone explain why I am getting this and how I can make it go away? NOTE: Changing the (int *) cast to (char *) causes the same warning.
countAddr.bytes[0] = tempBuff1[COUNT_ADDR - PWRD_ADDRESS];
countAddr.bytes[1] = tempBuff1[COUNT_ADDR - PWRD_ADDRESS + 1];
countAddr.bytes[2] = tempBuff1[COUNT_ADDR - PWRD_ADDRESS + 2];
countAddr.bytes[3] = tempBuff1[COUNT_ADDR - PWRD_ADDRESS + 3];
sendHexToASCII_UART((int *)countAddr.bytes[0], 4);