What is the correct way to avoid warnings on 64bit printf/scanf arguments on the most recent versions of mingw-w64?
I know that mingw-w64 relies on microsoft runtime for many standard library functions, and that these functions are not compatible with C99 standard.
Old answers say to use %I64d, but as the C99 standard is %lld, anyway if I compile with -Wall -pedantic I get warning for BOTH syntax, here is a small example:
#include <stdio.h>
int main(void)
{
long long test;
scanf("%I64d", &test);
scanf("%lld", &test);
}
Compile it with gcc (my version is mingw-w64 5.0.4, gcc 8.2.0):
x86_64-w64-mingw32-gcc -o test.exe test.c -Wall -pedantic
It gives the following warnings:
dev:tmp dev$ x86_64-w64-mingw32-gcc -o test.exe test.c -Wall -pedantic
test.c: In function ‘main’:
test.c:6:11: warning: ISO C does not support the ‘I64’ ms_scanf length modifier [-Wformat=]
scanf("%I64d", &test);
^~~~~~~
test.c:6:11: warning: ISO C does not support the ‘I64’ ms_scanf length modifier [-Wformat=]
test.c:7:14: warning: unknown conversion type character ‘l’ in format [-Wformat=]
scanf("%lld", &test);
^
test.c:7:11: warning: too many arguments for format [-Wformat-extra-args]
scanf("%lld", &test);
^~~~~~
test.c:7:14: warning: unknown conversion type character ‘l’ in format [-Wformat=]
scanf("%lld", &test);
^
test.c:7:11: warning: too many arguments for format [-Wformat-extra-args]
scanf("%lld", &test);
^~~~~~
Removing -Wall removes both warnings, without -pedantic I can compile without warnings line 6 (%I64d) but not line 7 (%lld).
-D__USE_MINGW_ANSI_STDIOfor a workaround. It might help you (?). - user694733