首先#pragma在本質上是聲明,經常使用的功能就是註釋,尤爲是給Code分段註釋;並且它還有另外一個強大的功能是處理編譯器警告,但卻沒有上一個功能用的那麼多。spa
clang diagnostic 是#pragma 第一個經常使用命令:指針
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-相關命令"
// 你本身的代碼
#pragma clang diagnostic pop
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wincompatible-pointer-types" // #pragma clang diagnostic pop
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wincompatible-pointer-types" // #pragma clang diagnostic pop
// completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" self.completionBlock = ^ { ... }; #pragma clang diagnostic pop
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" int a; #pragma clang diagnostic pop
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcovered-switch-default" // switch (style) { // case UITableViewCellStyleDefault: // case UITableViewCellStyleValue1: // case UITableViewCellStyleValue2: // case UITableViewCellStyleSubtitle: // // ... // default: // return; // } #pragma clang diagnostic pop