Ignore "Unused Object: Unused Variable" in a single file

I want to get rid of this compiler warning in only one file of my Xcode project. Is there any way to do this?

+4
source share
1 answer

You can disable special warnings in Clang using the pragmatic directive and the keyword "diagnostics" :

#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" // Insert code here #pragma clang diagnostic pop 

No unused warning variables will be generated for the code between the click and the pop file.

The second option, even more targeted, is to mark a specific variable with an attribute

 __attribute__((unused)) NSString * thisStringIsJustForFun = @"It only work if somebody makes you do it."; 
+10
source

Source: https://habr.com/ru/post/1498770/


All Articles