gcc with -Werror and -Wno-error=unused

bolov picture bolov · Feb 2, 2015 · Viewed 17k times · Source

I always compile with -Wall -Wextra -Werror.

However many times as I do quick compile tests I need to ignore the -Wunused suit of errors. For various reasons I want to see them as warnings and not errors while leaving all other warnings as errors.

  • -Wno-unused of course doesn't display any warning so is not what I need.

  • The one I thought is the solution -Wno-error=unused unfortunately doesn't seem to work (they are still reported as errors),

  • Individually setting the flags (e.g. -Wno-error=unused-variable) works as expected (reported as warning only).

So is there a way to make them warnings while leaving -Werror without to specify all the suit of options -Wno-error=unsused-... individually?
Is the behavior of -Werro -Wno-error=unused a bug?

Answer

Laser picture Laser · Feb 2, 2015

No there is no way to turn them off at once. -Wunused enable list of options like:
-Wunused-function
-Wunused-label
-Wunused-value
-Wunused-variable

And you should disable them one by one with Wnooption.