【2】-Wformat 用来消除printf /scanf中格式化的不正确使用 【3】-Wunused 用来消除未使用的已定义变量 【4】-Wimplicit 用来消除函数未声明 【5】-Wreturn-type 用来消除未函数没有返回值。 实际上不需要区分时直接使用-Wall,但一些其它选项如-W –Wconversion –Wshadow –Wcast-qual –Wwrite-strings -Wtrditi...
-Wformat-extra-args 当传递给格式字符串的参数太多时给出警告 -Wformat-nonliteral 当格式字符串不是字面值时给出警告 -Wformat-security 当使用格式字符串的函数可能导致安全问题时给出警告 -Wformat-y2k 当 strftime 格式给出 2位记年时给出警告 -Wformat-zero-length 对长度为 0 的格式字符串给出警告 -Wform...
-Wformat 检查标准库函数的使用格式是否正确,比如printf的格式化字符串中的格式符和对应的参数是否匹配 -Wunused-function 对已声明但是未定义的静态函数和未被使用的非内联静态函数发出警告 -Wswitch 当用switch用于枚举类型时,判断分支是否包含所有枚举值,否则发出警告 -Wunused-variable 对声明但未被使用的变量发出警告...
$ gcc -Wformat example4.c -o example4 或 $ gcc -Wall example4.c -o example4 GCC给出如下警告信息: example4.c: 在函数‘main’中: example4.c:5:5: 警告: 格式 ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double’ [-Wformat] 格式字符串和参数类型的不匹配会导...
-Wformat-nonliteral 当格式字符串不是字面值时给出警告 -Wformat-security 当使用格式字符串的函数可能导致安全问题时给出警告 -Wformat-y2k 当 strftime 格式给出 2 位记年时给出警告 -Wformat-zero-length 对长度为 0 的格式字符串给出警告 -Wformat= 此开关缺少可用文档 ...
-Wformat-y2k 当 strftime 格式给出 2位记年时给出警告 -Wformat-zero-length 对长度为 0 的格式字符串给出警告 -Wformat= 此开关缺少可用文档 -Wignored-qualifiers 当类型限定符被忽略时给出警告。 -Wimplicit 对隐式函数声明给出警告 -Wimplicit-function-declaration 对隐式函数声明给出警告 ...
warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=] printf("the number is %f\n",5); 5. gcc编译多个文件 假设现在有三个文件:hello.c hello.h main.c ,三个文件的内容如下: // hello.c#include<stdio.h>#include"hello.h"voidprintHello...
%{!fno-asynchronous-unwind-tables:-fasynchronous-unwind-tables} %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}} %{!Wformat:%{!Wformat=2:%{!Wformat=0:%{!Wall:-Wformat} %{!Wno-format-security:-Wformat-security...
/usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu test.c -quiet -dumpbase test.c -mtune=generic -march=x86-64 -auxbase test -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o ...
#pragma GCC diagnostic ignored "-Wall -Wformat=2 -Wconversion -Wsign-conversion -Wshadow" 如果需要忽略 -Wformat=2,应该使用忽略-Wformat。 //编译错误 #pragma GCC diagnostic ignored "-Wformat=2" //正确 #pragma GCC diagnostic ignored "-Wformat" 错误最后...