28

I know that #pragma clang diagnostics can be used for ignoring some warnings generated by clang. But I don't know how to use this correctly.

For example, for an unused variable warning we can avoid warning by

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"

int number;

#pragma clang diagnostic pop

But I don't know how to get correct parameter for #pragma clang diagnostic ignored ("-Wunused-variable" here)

Is there any way to fing this kind of warning name for specific warnings with xcode?

Victor Häggqvist
  • 4,484
  • 3
  • 27
  • 35
Johnykutty
  • 12,091
  • 13
  • 59
  • 100
  • This question may help you with the right syntax for using the diagnostic tool http://stackoverflow.com/questions/14444203/dynamic-forwarding-suppress-incomplete-implementation-warning/14444603#14444603 – Popeye Nov 25 '14 at 08:17

3 Answers3

34

Right click on the issue in the issue navigator and select "Reveal in Log". The error message will specify the warning.

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
iOS Gamer
  • 476
  • 5
  • 8
  • 1
    I don't see that option anymore , only reveal in symbols or in finder. how does this work on xcode 5? – user1028028 Feb 27 '14 at 07:46
  • 1
    OK, so for you guys that are seeing the option grayed out (@user1028028 and @Stas). You need to build first. Then after your build finished do the same thing. The option won't be grayed out. If you try introducing a new error/warning after this, the contextual menu option will be grayed out only for the new warning/error. Basically, you need to generate the log by building first. Hope this still helps! Cheers – iOS Gamer Apr 17 '14 at 20:49
20

You can look up the warning command line parameter if you know the message: Diagnostic flags in Clang

AndiDog
  • 68,631
  • 21
  • 159
  • 205
1

Ok, then this is what I understood

Clang is the C/Objective C Front end Layer for compiler. and Clang take the responsibility of showing Warning and Error message that we see in Xcode.

So when you enable the option of treat your warning as Error in Xcode, In some cases you need a tool to work around about the Clang to allow some warnings..

and here Clang Diagnostics play that role..

and the mechanism for that is like Graph Matrix, which is happened in Stack way..Push and Pop..

so when you have something like this..

#pragma clang diagnostic push

#pragma clang diagnostic ignored "-Wcovered-switch-default"

// Code.........

#pragma clang diagnostic pop

you are preventing Clang to show warning messages on that area, so it something like SafeArea..

animuson
  • 53,861
  • 28
  • 137
  • 147
Atef
  • 2,872
  • 1
  • 36
  • 32