I was experimenting with some c programming and encountered an error in which gcc issues the warning:
warning: unknown conversion type character 'h' in format [-Wformat=]
21 | printf("This bytes value is %hhu \n", *i);
| ^
with "i" being a char pointer I use to read some data byte by byte.
After some research, I learned that this feature has been included since C99.
I am currently using C17 (_STDC_VERSION_ 201710L) and GCC 12.2. Therefore this feature should be included.
I recently switched to Chocolatey for managing MinGW. Before I had an older version of C manually installed and used which I removed with the switch. Could this be an issue?
I don't see why the compiler struggles to interpret this besides maybe using the wrong stdio.h version, but I can't seem to fix this.
Here is the remaining part of this experiment in case that this could be relevant:
#include <stdio.h>
typedef struct{
char hight;
char width;
char data[3];
} Byte_Buffer;
int main (int argc, char **argv)
{
Byte_Buffer buffer;
printf ("size of buffer is %lu \n",(unsigned long) sizeof buffer);
char* i =(char *) &buffer;
for(char* end = (char*) &buffer + sizeof buffer; i <= end ; i++)
{
printf("This bytes (%p) value is %hhu \n", i,*i);
}
return 0;
}
The code works fine using %hu or % u instead btw.
Thanks for the help :)