我正试图long long从控制台使用标准IO功能scanf.我开始时%lld:
scanf("%lld", &rule);
Run Code Online (Sandbox Code Playgroud)
抛出:
error: unknown conversion type character 'l' in format [-Werror=format=]
Run Code Online (Sandbox Code Playgroud)
我发现了更多变通方法,但它们也会抛出错误:
scanf("%I64d", &rule);
->error: ISO C does not support the 'I64' ms_scanf length modifier [-Werror=format=]
scanf("%"SCNd64"", &rule);
->error: expected ')' before 'SCNd64'
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?还有另外一招吗?
我正在使用这些标志编译最新版本的MinGw GCC: -pedantic -Wall -Werror -std=c99 -g -D HOME=1
我通过Mingw在Windows上编写了一个linux程序.但是,程序的输出在Windows上看起来与在Linux上不同.
例如,在Windows上输出是这样的(我得到'zu'而不是实数):
Approximated minimal memory consumption:
Sequence : zuM
Buffer : 1 X zuM = zuM
Table : 1 X zuM = zuM
Miscellaneous : zuM
Total : zuM
Run Code Online (Sandbox Code Playgroud)
在Linux上,原始程序编译(没有Mingw)警告.在Windows上,在Mingw下,它编译为零警告.
有什么我应该知道的吗?
Mingw是否提供100%的兼容性,或者我必须修改程序才能在Win上运行?
我不知道在哪个方向前进.我应该在哪里开始尝试修复程序?
你认为我有更好的机会与Cygwin?
更新:
维基百科提到:"缺乏对C99的支持导致了移植问题,特别是涉及printf样式转换说明符的问题".
这是我碰到头的事吗?
更新:
我的mingw版本是:
MINGWBASEDIR=C:\MinGW
gcc version 4.8.1 (GCC)
gcc version 4.8.1 (GCC)
GNU gdb (GDB) 7.6.1
GNU ld (GNU Binutils) 2.24
GNU windres (GNU Binutils) 2.24
GNU dlltool (GNU Binutils) 2.24
GNU Make 3.82.90
#define __MINGW32_VERSION 3.20
#define __W32API_VERSION 3.17
Run Code Online (Sandbox Code Playgroud)
(我使用此代码获取版本:
@echo off
REM …Run Code Online (Sandbox Code Playgroud)