Reputation:
I am trying to use scanf()
for reading an unsigned char value with %hhu
, but the compiler returned me:
error: unknown conversion type character 'h' in format
[-Werror=format]| // line 3 error: too many arguments for format
[-Werror=format-extra-args]| // line 3
With this following code:
printf("Enter a number: ");
unsigned char nb;
scanf("%hhu", &nb); // line 3
printf("Number: %u\n", nb);
return (nb);
Upvotes: 7
Views: 2719
Reputation: 26800
A discussion on this issue can be found here.
This is specific to MinGW.
From this comment in the discussion the issue is identified as:
This is most likely related to bug https://sourceforge.net/p/mingw-w64/bugs/652/ in that the include order and compiler driver actually screws things up with respect to C standard output and format specifiers.
And is proposed solution is:
to always define __USE_MINGW_ANSI_STDIO so that the newer ansi format specifiers can be used and to ensure that long double (at least) is not passed between MSVC compiled and gcc compiled code.
Upvotes: 1