gcc disable - 特定文件/文件夹的标志

gmu*_*mad 3 c c++ android gcc makefile

我的项目中有一些开源库文件(例如:http://nothings.org/stb_vorbis/stb_vorbis.c).-Wall选项在我的Android.mk文件中启用.在编译期间,stb_vorbis.c中会生成几个警告.

warning: unused variable <var>
warning: statement with no effect
warning: <var> defined but not used
warning: <var> may be used uninitialized in this function
Run Code Online (Sandbox Code Playgroud)

出于某种原因,我不想修改stb_vorbis.c但仍希望-Wall选项可用于我自己的源文件.有没有办法禁用特定文件/文件夹的-Wall选项?

Lee*_*hem 5

有没有办法禁用特定文件/文件夹的-Wall选项?

我不相信有任何gcc可用于实现这一目标的选择.您需要更改用于编译有问题的源文件的Makefile.

你可以做点什么

CFLAGS:=$(filter-out -Wall, $(CFLAGS))
Run Code Online (Sandbox Code Playgroud)

在Makefile中stb_vorbis,如果你的make支持filter-out功能.

你也可以为此写一个特定的规则stb_vorbis.c:

STB_VOBIS_CFLAGS:=$(filter-out -Wall, $(CFLAGS))
stb_vorbis.o: stb_vorbis.c ...
        $(CC) $(STB_VOBIS_CFLAGS) -o $@ -c $<
Run Code Online (Sandbox Code Playgroud)