我正在尝试使用标准 IO 函数 scanf
从控制台获取 long long
。我从 %lld
开始:
scanf("%lld", &rule);
抛出:
error: unknown conversion type character 'l' in format [-Werror=format=]
我找到了 more workarounds ,但它们也会抛出错误:
scanf("%I64d", &rule);
->error: ISO C does not support the 'I64' ms_scanf length modifier [-Werror=format=]
scanf("%"SCNd64"", &rule);
->error: expected ')' before 'SCNd64'
我做错了什么吗?还有其他技巧吗?
我正在使用这些标志在最新版本的 MinGw GCC 上进行编译:-pedantic -Wall -Werror -std=c99 -g -D HOME=1
最佳答案
我也想添加这个片段:
MinGW-w64 - for 32 and 64 bit Windows / [Mingw-w64-public] -Wformat and %llu
the issue is that formatter-width specifier %ll isn't supported for all msvcrt-DLL versions, therefore gcc warns about its use. The variant for specifying 64-bit integer-scalar-width in formatter for msvcrt in a backward-compatible way is by using %I64.
Use %I64u on Windows, or just use inttypes.h PRIuMAX.
If you must use %llu, define __USE_MINGW_ANSI_STDIO macro before including stdio.h. Be aware that if you do this, MS type %I64* format will no longer work.
关于c - 错误 : unknown conversion type character 'l' in format - scanning long long,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23718110/