[iOS development] turn compiler warning on/off

Source: Internet
Author: User

  1. Global on/Off
    1. "Build Settings", "Apple llvm-warnings" Select the warning you need to turn on/off
    2. "Build Settings", "Apple llvm-custom Compiler Flags", add an identity to turn on- W ..., turn off identify as -wno ...
        1. -wall not all warnings. This warning group is open to compiler developers who have a high level of confidence in the proposition "there is a problem in the code you wrote." If you have a warning in this set of settings, it's basically that your code really has a serious problem. But at the same time, it's not that it's all right to open wall, because wall is just a handful of the classic codebase, so there are some deadly warnings that can't be captured. However, because wall warnings provide a high level of confidence and priority warnings, it should be a good practice to open this set of warnings for all projects (at least all new projects).
        2. -wextra as its name, the-wextra group provides an "extra" warning. This group is almost as useful as the-wall group, but in some cases the code is relatively harsh. A very common example is the inclusion of-wsign-compare in-wextra, which will turn on the comparison of signed and unsigned type checks when the comparator is signed on either side of the unsigned, creating a warning. In fact, a lot of code does not pay particular attention to such comparisons, and most of the time, the comparison of signed and unsigned is not too much of a problem (of course, do not rule out a fatal error occurs). It is important to note that-wextra and-wall are independent two warning groups, although there are individual duplicates of the warning signs that are open inside, but the two groups do not contain relationships. If you want to use it at the same time, you must add it to other C flags.
        3. -weverything This is really all the warnings. However, the general developer does not choose to use this identity because it contains warning hints that may still exist in the development of the bug. This logo is typically used by compiler developers for debugging, and if you want to open it in your own project, the warning will be so bursting that you want to start banging on the wall.
  2. Open/close for specific files
    1. "Build phases", "Compile Sources", adding an identity to the "Compiler Flags" of the specified file
  3. Turn on/off for a specific line of code
    1. 1 #pragma 2 #pragma 3   4 #pragma clang diagnostic pop

[iOS development] turn compiler warning on/off

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.