iOS常用的忽略警告类型:
1, 方法弃用警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//过期的方法
#pragma clang diagnostic pop
2, 不兼容指针类型警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
//不兼容指针类型
#pragma clang diagnostic pop
3, 循环引用警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
//循环引用
#pragma clang diagnostic pop
4, 未使用变量警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
//未使用的变量
#pragma clang diagnostic pop
5, 内存泄漏警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
//内存泄漏警告
#pragma clang diagnostic pop
宏定义消除警告
#pragma mark - /**************** Clang ****************/
#define ArgumentToString(macro) #macro
#define ClangWarningConcat(warning_name) ArgumentToString(clang diagnostic ignored warning_name)
// 参数可直接传入 clang 的 warning 名,warning 列表参考:http://fuckingclangwarnings.com/
#define BeginIgnoreClangWarning(warningName) _Pragma("clang diagnostic push") _Pragma(ClangWarningConcat(#warningName))
#define EndIgnoreClangWarning _Pragma("clang diagnostic pop")
#define BeginIgnorePerformSelectorLeaksWarning BeginIgnoreClangWarning(-Warc-performSelector-leaks)
#define EndIgnorePerformSelectorLeaksWarning EndIgnoreClangWarning
#define BeginIgnoreAvailabilityWarning BeginIgnoreClangWarning(-Wpartial-availability)
#define EndIgnoreAvailabilityWarning EndIgnoreClangWarning
#define BeginIgnoreDeprecatedWarning BeginIgnoreClangWarning(-Wdeprecated-declarations)
#define EndIgnoreDeprecatedWarning EndIgnoreClangWarning