iOS常用的忽略警告類型:
1, 方法棄用警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//過(guò)期的方法
#pragma clang diagnostic pop
2, 不兼容指針類型警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
//不兼容指針類型
#pragma clang diagnostic pop
3, 循環(huán)引用警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
//循環(huán)引用
#pragma clang diagnostic pop
4, 未使用變量警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
//未使用的變量
#pragma clang diagnostic pop
5, 內(nèi)存泄漏警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
//內(nèi)存泄漏警告
#pragma clang diagnostic pop
宏定義消除警告
#pragma mark - /**************** Clang ****************/
#define ArgumentToString(macro) #macro
#define ClangWarningConcat(warning_name) ArgumentToString(clang diagnostic ignored warning_name)
// 參數(shù)可直接傳入 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