我的项目中有一些开源库文件(例如: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
出于某种原因,我不想修改 stb_vorbis.c,但仍希望 -Wall 选项可用于我自己的源文件。有什么方法可以禁用特定文件/文件夹的 -Wall 选项吗?
最佳答案
Is there any way to disable -Wall option for specific files/folder ?
我不相信有任何 gcc
选项可以用来实现这一点。您需要更改用于编译有问题的源文件的 Makefile。
你可以做类似的事情
CFLAGS:=$(filter-out -Wall, $(CFLAGS))
在 stb_vorbis
的 Makefile 中,如果您的 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 $<
关于android - gcc disable -Wall 特定文件/文件夹的标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22472894/