Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc disable -Wall flag for specific files/folders

I have some open source library files in my project (e.g: http://nothings.org/stb_vorbis/stb_vorbis.c). -Wall option is enabled in my Android.mk file. During compilation several warnings are generated in 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

For some reason I do not want to modify stb_vorbis.c but still want the -Wall option to be available for my own source files. Is there any way to disable -Wall option for specific files/folder ?

like image 404
gmuhammad Avatar asked Oct 25 '25 12:10

gmuhammad


1 Answers

Is there any way to disable -Wall option for specific files/folder ?

I do not believe there is any gcc option that could be used to achieve this. You need to change your Makefile that you used to compile the problematic source files.

You could do something like

CFLAGS:=$(filter-out -Wall, $(CFLAGS))

in the Makefile for stb_vorbis, if your make supports filter-out function.

Also you could write a specific rule for that stb_vorbis.c:

STB_VOBIS_CFLAGS:=$(filter-out -Wall, $(CFLAGS))
stb_vorbis.o: stb_vorbis.c ...
        $(CC) $(STB_VOBIS_CFLAGS) -o $@ -c $<
like image 70
Lee Duhem Avatar answered Oct 28 '25 02:10

Lee Duhem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!