Nickolay Kondratyev
Nickolay Kondratyev

Reputation: 5211

Quick way to override -Werror flag?

If cc configuration is set to use -Werror is there a way to override -Werror flag from the terminal when using make?

Upvotes: 14

Views: 26723

Answers (2)

KJ7LNW
KJ7LNW

Reputation: 1901

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.

Upvotes: 0

blahdiblah
blahdiblah

Reputation: 33991

You can set flags when invoking make:

CFLAGS=-Wno-error make

Upvotes: 19

Related Questions