去除警告的方法:
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wunused-function"
local void free_linkedlist(ll)
linkedlist_data* ll;
{
free_datablock(ll->first_block);
ll->first_block = ll->last_block = NULL;
}
#pragma clang diagnostic pop
上述的代碼塊中府寒,正常的代碼是沒有下方這些代碼的凤优。但是呢,這個方法我是已經(jīng)寫了题涨,但是在項目中沒有運用到偎谁,所以會報出這樣的錯誤,如圖錯誤信息圖所示:
代碼塊:
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wunused-function"
// edit code
#pragma clang diagnostic pop
錯誤信息圖:
在Xcode中選中警告的消息纲堵,右擊選擇Reveal in Log巡雨,然后右邊會有報告的消息
-Wunused-function
所以上面去除警告是使用
-Wunused-function
這個來寫的。其他的警告同理做法就能去除席函。
示例:
我們知道铐望,UIAlertView雖然簡單易用,但是呢Apple在iOS 9.0的時候丟棄這個類了茂附,我們在其頭文件中可以看到
NS_CLASS_DEPRECATED_IOS(2_0, 9_0, "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead") __TVOS_PROHIBITED
所以平時用到這個方法的時候正蛙,項目中Xcode就會給這個地方給出警告。但是也有辦法處理這樣的警告营曼,如下圖所示:
<p>
下方羅列出來是一些iOS中常見的一些警告消息乒验,在使用第三方庫或者Apple官方過時的方法的時候,都會報警告溶推。
Warning | Message |
---|---|
-WCFString-literal | input conversion stopped due to an input byte that does not belong to the input codeset UTF-8 |
-WNSObject-attribute | __attribute ((NSObject)) may be put on a typedef only, attribute is ignored |
-Wabstract-vbase-init | initializer for virtual base class %0 of abstract class %1 will never be used |
-Waddress-of-array-temporary | pointer is initialized by a temporary array, which will be destroyed at the end of the full-expression |
-Warc-maybe-repeated-use-of-weak | "weak %select{variable property implicit property instance variable}0 %1 may be accessed multiple times in this %select{function method block lambda}2 and may be unpredictably set to nil assign to a strong variable to keep the object alive |
-Warc-non-pod-memaccess | %select{destination for source of}0 this %1 call is a pointer to ownership-qualified type %2 |
-Warc-performSelector-leaks | performSelector may cause a leak because its selector is unknown |
-Warc-repeated-use-of-weak | "weak %select{variable property implicit property instance variable}0 %1 is accessed multiple times in this %select{function method block lambda}2 but may be unpredictably set to nil assign to a strong variable to keep the object alive |
關(guān)于附件更多信息至鏈接iOS 項目警告處理(附表)