If cc configuration is set to use -Werror
is there a way to override -Werror
flag from the terminal when using make?
Quick way to override -Werror flag?
You can set flags when invoking make:
CFLAGS=-Wno-error make
This probably won't work. Most makefiles have a default setting of CFLAGS, something like
CFLAGS = -O2 -g
or something. In order to override that you have to pass the assignment on the command line not in the environment: run make CFLAGS=-Wno-error
instead. –
Fusible @Fusible Good point, but if you pass the CFLAGS assignment as an argument to
make
it'll clobber whatever would've been set and potentially break the build entirely (unless only -Werror
was set). If that's the case, then the best way is really via ./configure --extra-cflags
if available. –
Whew If you have a specific warning, you can remove only that particular warning to error conversion, so other errors will still trigger. This is useful if you know you'll hit the error in your build but do not wish to disable all warnings-errors in case others may be useful.
For example, if you get this warning (error):
error: format not a string literal, format string not checked [-Werror=format-nonliteral]
then use format-nonliteral
in -Wno-error=<err>
as follows:
CFLAGS=-Wno-error=format-nonliteral
Also note: It is possible that you'll need to redo ./configure
if make
doesn't pick up CFLAGS
directly:
CFLAGS=-Wno-error=format-nonliteral ./configure <options>
make
For C++ you would use CXXFLAGS
instead of (or in addition to) CFLAGS
.
© 2022 - 2024 — McMap. All rights reserved.
-Wno-error
afterward to the compiler, probably putting inCFLAGS
in the makefile will do. – Nationwidefind . -name Makefile -or -name '*m4' -exec sed -i s/-Werror//g {} \;
Be sure to make a backup before using as it may break things. You may have to adjustfind
to find files that contains make definitions. – Intercut