I am trying to assign string to uint8_t
buffer in IAR, but I get a warning message.
rx_buffer.rx_struct.RESP.RESPOND
is struct field
of uint8_t
type.
My code is:
strncpy(rx_buffer.rx_struct.RESP.RESPOND, (uint8_t *)'NS,', 3);
And the associated warning message is the following:
Warning[Pe1422]: multicharacter character literal (potential portability problem)
Warning[Pe167]: argument of type "uint8_t *" is incompatible with parameter of type "char *",
Warning[Pe167]: argument of type "uint8_t *" is incompatible with parameter of type "char const"
I have written a workaround :
rx_buffer.rx_struct.RESP.RESPOND[0] = 'N';
rx_buffer.rx_struct.RESP.RESPOND[1] = 'S';
rx_buffer.rx_struct.RESP.RESPOND[2] = ',';
But I'm not satisfied with it. What is the correct way to do that?