Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible to suppress a specific clang warning on Mac OS X

I have set -Wno-unused-parameter (and some others) compiler flag, and it is indeed passed to the compiler, but I'm still getting this warning:

clang++ -c -pipe -Wno-self-assign -Wno-unused-parameter -Wno-unused-variable -g -gdwarf-2 -arch x86_64 -fPIC -Wall -W F/Library/Frameworks -o ../build/cobject.o src/cobject.cpp                                                     ^
src/cobject.cpp:102:68: warning: unused parameter 'client' [-Wunused-parameter]
void cobject::processNetMsg( int type, CNetMsg& msg, CClient& client )
                                                                   ^

Is it because -Wall is also specified? Shouldn't -Wno-... take precedence? How to tell clang to display all warnings except for some?

like image 432
Violet Giraffe Avatar asked Apr 17 '13 08:04

Violet Giraffe


People also ask

How do I turn off clang warning?

Using _Pragma to suppress the warning. Using #pragma to suppress the warning. Using command line options to suppress the warning.

How do I silence a warning in Xcode?

If you want to disable all warnings, you can pass the -suppress-warnings flag (or turn on "Suppress Warnings" under "Swift Compiler - Warning Policies" in Xcode build settings).

How do I turn off GCC warning?

To answer your question about disabling specific warnings in GCC, you can enable specific warnings in GCC with -Wxxxx and disable them with -Wno-xxxx. From the GCC Warning Options: You can request many specific warnings with options beginning -W , for example -Wimplicit to request warnings on implicit declarations.

Does Macos come with clang?

From Xcode 4.2, Clang is the default compiler for Mac OS X.


1 Answers

The warning arguments acts like toggles. When you do e.g. -Wno-unused-parameter you turn off that warning, however later on the command line you do -Wall which turns it back on again. The order of the arguments matter.

So to solve it, place the off-argument after it's turned on.

like image 132
Some programmer dude Avatar answered Sep 21 '22 11:09

Some programmer dude