#pragma GCC diagnostic 编译器警告
2017-07-28 本文已影响88人
罗淞
方法弃用警告
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
backgroundConfiguration = [NSURLSessionConfiguration backgroundSessionConfiguration:self.backgroundSessionIdentifier];
#pragma GCC diagnostic pop
中间代码是弃用代码只支持iOS7-iOS8,当前编译器会报黄色警告。
当我们要支持不同版本时,为了去掉警告可以使用此方法。
不兼容指针类型
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
//
#pragma clang diagnostic pop
retain cycle
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ {
...
};
#pragma clang diagnostic pop
#pragma clang diagnostic pop
未使用变量
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
int a;
#pragma clang diagnostic pop
原文:http://blog.csdn.net/mamong/article/details/24542107
参考链接:
http://nshipster.com/pragma/
http://www.cocoachina.com/applenews/devnews/2013/0731/6707.html
看这个就行了 -》http://fuckingclangwarnings.com/