[Ios]clang Diagnostic, Wprotocol.

Source: Internet
Author: User

First, #pragma is essentially a declaration,一般常用的功能就是打注释、尤其是分段注释

但是#pragma 另外一个强大的功能就是处理编译器警告,用的时候可能就没上一个

功能用的那么多,在代码中处理警告却是极其高效的方法。

其中 clang diagnostic 便是#pragma 第一个功能常用的命令,步骤如下

#pragma clang diagnostic push#pragma clang diagnostic ignored "-related commands"    //Your own code #pragma clang diagnostic pop

常见用法

1.方法弃用告警

    #pragma clang diagnostic push            #pragma clang diagnostic ignored "-wdeprecated-declarations"           [TestFlight Setdeviceidentifier:[[uidevice Currentdevice] uniqueidentifier];            #pragma clang diagnostic pop   

2. Incompatible pointer types

    #pragma clang diagnostic push       #pragma clang diagnostic ignored "-wincompatible-pointer-types"       //      #pragma Clang Diagnostic Pop  

3. Circular references

    Completionblock is manually the retain cycle of nilled out and afurlconnectionoperation to break.      #pragma clang diagnostic push      #pragma clang diagnostic ignored "-warc-retain-cycles"          Self.completionblock = ^ { c9/> ...          };      #pragma clang diagnostic pop  

4. No variables used

#pragma clang diagnostic push   #pragma clang diagnostic ignored "-wunused-variable"     int A;   #pragma clang diagnostic pop  


#pargma 用法详情:

http://nshipster.cn/pragma/

http://nshipster.com/clang-diagnostics/

相关的命令列表

http://fuckingclangwarnings.com/


Advanced:

Http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas



[Ios]clang Diagnostic, Wprotocol.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.