code:
int8_t ret;
int8_t buf[8];
bytes_written = snprintf(buf, 8, "%" PRId8, 2);
warning:
warning: pointer targets in passing argument 1 of ‘snprintf’ differ in signedness [-Wpointer-sign]
bytes_written = snprintf(buf, 8, "%" PRId8, 2);
^
/usr/include/stdio.h:386:12: note: expected ‘char * __restrict__’ but argument is of type ‘int8_t *’
extern int snprintf (char *__restrict __s, size_t __maxlen,
I know this can be fixed by taking buf as *char, but
int8_t is typedef as unsigned char
checked with pre-processor output i.e. gcc main.c | grep int8_t
So why compiler is not able to understand that?
With buf as uint8_t also I get the same warning.
Edit:
int8_t is typedef as signed char (By mistake I have written as unsigned in original post)