{gcc 'hellowo.c' -o 'hellowo.exe' -Wall -g -O2 -static-libgcc -std=c11 -fexec-charset=GBK}
并且版本信息是
gcc version 8.1.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)
当我尝试时
#include <stdio.h>
int main(void)
{
float float1 = 64.25f;
printf("%zd\n",sizeof(int));
printf("%a",float1); //float1=64.25f
return 0;
}
编译器警告我:
hellowo.c: In function 'main':
hellowo.c:6:12: warning: unknown conversion type character 'z' in format [-Wformat=]
printf("%zd\n",sizeof(int));
^~~~~~~
hellowo.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
hellowo.c:6:12: warning: unknown conversion type character 'z' in format [-Wformat=]
hellowo.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
hellowo.c:7:12: warning: unknown conversion type character 'a' in format [-Wformat=]
printf("%a",float1); //float1=64.25f
^~~~
hellowo.c:7:12: warning: too many arguments for format [-Wformat-extra-args]
hellowo.c:7:12: warning: unknown conversion type character 'a' in format [-Wformat=]
hellowo.c:7:12: warning: too many arguments for format [-Wformat-extra-args]
但是输出是
4
0x1.010000p+6
为什么会发生这种情况,我正在使用的示例自行研究]很奇怪,.exe可以正常工作,并且我的程序可以成功编译。C引物加
我尝试将%zd修改为%zu,(“%zd”语句是
C引物加
的示例]仍然有警告:hellowo.c:6:12: warning: unknown conversion type character 'z'
in format [-Wformat=]
printf("%zu\n",sizeof(int));
^~~~~~~
hellowo.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
hellowo.c:6:12: warning: unknown conversion type character 'z'
in format [-Wformat=]
hellowo.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
Mingw-w64 gcc编译器为什么会生成关于%zd和%a格式的错误警告?
我正在使用gcc编译器,命令行为{gcc'hellowo.c'-o'hellowo.exe'-Wall -g -O2 -static-libgcc -std = c11 -fexec-charset = GBK}和该版本信息是gcc版本8.1.0(x86_64 -...
这是不完整的答案。