Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

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..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top