Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc with -Werror and -Wno-error=unused

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?

like image 208
bolov Avatar asked Feb 02 '15 13:02

bolov


People also ask

What are the GCC options?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker.

What is fPIC option in GCC?

fPIC option in GCC enables the address of shared libraries to be relative so that the executable is independent of the position of libraries. This enables one to share built library which has dependencies on other shared libraries. fPIC stands for "force Position Independent Code".

Is Visual Studio better than GCC?

In the question“What are the easiest to use C++ compilers and IDEs?” Microsoft Visual C++ is ranked 2nd while GCC is ranked 3rd. The most important reason people chose Microsoft Visual C++ is: To get C++ running on a build machine, just copy the VC bin, and all the headers/libraries you'll need.


1 Answers

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.

like image 172
Laser Avatar answered Oct 11 '22 22:10

Laser