- Global on/Off
- "Build Settings", "Apple llvm-warnings" Select the warning you need to turn on/off
- "Build Settings", "Apple llvm-custom Compiler Flags", add an identity to turn on- W ..., turn off identify as -wno ...
- -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).
- -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.
- -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.
- Open/close for specific files
- "Build phases", "Compile Sources", adding an identity to the "Compiler Flags" of the specified file
- Turn on/off for a specific line of code
1 #pragma 2 #pragma 3 4 #pragma clang diagnostic pop
[iOS development] turn compiler warning on/off