error: format '%d' expects a matching 'int' argument [-Werror=format] c++ - Gcc忽略-Wno-unused-variable - IT工具网 反过来: -Wno-error取消编译选项-Werror 实例2: 假设我们使用了一个人的代码A目录,里面有一个-Werror的选项,把所有的警告当做错误;又使用了另一个人的代码B目录,里面存在一堆Warning。
◆unused-function:遇到仅声明过但尚未定义的静态函数时发出警告。 ◆unused-label:遇到声明过但不使用的标号的警告。 ◆unused-parameter:从未用过的函数参数的警告。 ◆unused-variable:在本地声明但从未用过的变量的警告。 ◆unused-value:仅计算但从未用过的值得警告。 ◆Format:检查对printf和scanf等函数的调用,...
gcc -c -Wno-unused-function -Wno-unused-variable source_file.c 其中,-c 选项表示只编译源代码文件,不链接生成可执行文件;-Wno-unused-function 和-Wno-unused-variable 选项分别表示忽略未使用的函数和变量的警告。 如果有多个源代码文件,可以将它们全部编译: 代码语言:txt 复制 gcc -c -Wno-unused-...
2. 在gcc编译命令中添加对应参数来忽略指定warning GCC提供了多种方法来忽略警告,包括在编译命令中添加特定的选项。 方法一:使用 -Wno- 前缀 对于大多数警告,你可以使用 -Wno- 前缀加上警告的代码来忽略该警告。例如,要忽略未使用变量的警告,可以使用 -Wno-unused-variable 选项。 bash gcc -Wno-unused-variable...
test.c:6:13: warning: unused variable ‘a_num’ [-Wunused-variable]inta_num;^~~~g++ -fno-common -fmessage-length=0-Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -shared -o -fPIC -o libfunc.a test.o 假如...
test_unused.c:37: warning: unused parameter `a'test_unused.c: In function `func5':test_unused.c:42: warning: unused variable `a'test_unused.c: In function `func6':test_unused.c:48: warning: statement with no effecttest_unused.c: At top level:test_unused.c:6: warning: `func1' ...
一般启用特定类型警告的格式为 -Wxxx,排除特定类型的警告的格式为 -Wno-xxx。比如使用 -Wall -Wno-unused-variable 可以从- Wall 中排除 -Wunused-variable。 如果希望某些类型的警告被视为错误,可以使用 -Werror=xxx,比如-Werror=switch;反之,则可以使用 -Wno-error=xxx 不将该类型警告视为错误,比如 -Wno-...
[GCC]GCC warning介绍 是一种诊断消息,用于报告那些本身并无错误但有风险或暗示可能存在错误的构造。 开启和关闭告警方法 -w (小写)禁止所有警告消息。 以“-W”(大写)开头开启特定的警告; 例如: -Wreturn-type(返回值告警), -Wsign-compare(有符号和无符号对比告警)...
test_unused.c:25: warning: `func2' defined but not used test_unused.c:14: warning: `var1' defined but not used [-Wuninitialized] 该警告选项用于检查一个局部自动变量在使用之前是否已经初始化了或者在一个longjmp调用可能修改一个non-volatile automatic variable时给出警告。目前编译器还不是那么smart...
wrong.c:4:warning:return type of'main'is not'int' wrong.c:In function'main': wrong.c:5:warning:unused variable'tmp' 可以看出,使用”-Wall”选项找出了未使用的变量tmp以及返回值的问题,但没有找出无效数据类型的错误。 2.非Wall类警告提示 ...