Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang (in Xcode): start with -Weverything and manually disable particular warnings

People also ask

How do I turn off clang warning?

Passing -fno-diagnostics-show-option will prevent Clang from printing the [-Wextra-tokens] information in the diagnostic. This information tells you the flag needed to enable or disable the diagnostic, either from the command line or through #pragma GCC diagnostic.

How do I turn off GCC warnings?

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.

What is clang diagnostic?

clang::Diagnostic Class Reference. A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) that allows clients to enquire about the currently in-flight diagnostic.

How do I turn off warnings 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).


You can disable individual warnings using -Wno-XYZ, XYZ being the name of the warning feature to be disabled.


XCode

In XCode 5 I had to build, then right click on an issue and select "Reveal in Log" then set the Middle Pane tab to "All" too get the issues displayed in the log.

Then clicking on the "Hamburger" Icon to the right and scrolling down I finally got an exact description of the Warning.

/.../SettingsViewController.m:91:58: warning: creating selector for nonexistent method 'setSegueIdentifier:' [-Wselector]
    [segue.destinationViewController performSelector:@selector(setSegueIdentifier:)

So in my case the following does the job.

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wselector"
...
#pragma clang diagnostic pop

I just bumped into a site that lists all Clang warnings and the flags that disable them (using #pragma clang diagnostic ignored "-Wxyz"):

http://goo.gl/hwwIUa (when you visit it you'll understand why I've shortened the URL).


I'm guessing you know how to update the build settings to enable/disable individual warnings and want to disable the warning in your code. Here is an example:

#ifdef TESTFLIGHT_USERTRACKING

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wdeprecated-implementations"

[TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];

#pragma clang diagnostic pop

#endif