How to remove some type of warning from the Xcode project implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32

Source: Internet
Author: User

Problem description in our project, often use a lot of third-party code, the code may be very complex, we do not dare to change them, but the author has stopped updating, when the SDK upgrade or the compiler upgrade, these legacy code may appear many warnings, So we have no way to get rid of these annoying warnings, or a project hundreds of warnings, you look at all the uncomfortable. How do we get rid of the warning?
1. The most direct, one-time, safest way to directly find the warning code, instead of warning. This way, the safest. But it has a problem, that is, when many of our files have this type of warning, we need to change a lot of source code, for not we write the source code, It may be updated at any time, and it is obviously not advisable for us in this way.
2. Use the macros provided by the compiler to operate, this way in our project will be a lot of see#pragma clang diagnostic push #pragma clang diagnostic ignored"-wdeprecated-declarations" //write in the middle of the code, will not be prompted by the compiler-wdeprecated-declarations types of warnings
dispatch_queue_tCurrentqueue =Dispatch_get_current_queue();#pragma clang diagnostic pop
The problem of this way, the same as the first, but also to modify the implementation of the source code, for the third party, we certainly do not want to change it, especially some update very frequent third parties, the general warning appears shortly after the author updated, we do this in this operation, it seems wasteful. and in When adding arm64 support, it's a bit of a time-consuming effort to have hundreds of of some kinds of warnings.For example, our project, opened the arm64, and then compiled


3. Close a warning of a specified type for a specified file here, take a concrete project. For example, we have a file in our project Presencepacket

In fact, it is simple to close some type of warning for a specified file, as if we had previously added arc support to a file or not supported, adding ignore/show some type warning
Double-click the file to add-wno-shorten-64-to-32 (this key is to let the compiler ignore implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') To ' int32_t ' (aka ' int ') warning)
After the add is finished, then compile, then the implicit in the Presencepacket file conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32_t ' (aka ' I NT ') warning is not, is not very simple, very convenient.


This way, has been greatly reduced the workload, only need to add-wno-shorten-64-to-32 in the compilation of the specified file. So is there any way that the compiler can ignore the warnings of the specified type throughout the project?
4. Close the warning of the specified type in the project the simplest, the target of the project has an other Warning Flags
Where to add-wno-shorten-64-to-32
Re-compile, haha, the entire file in the implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32_t ' (aka ' int ') warning all disappeared!! !!

5. You may be wondering how the above-wno-shorten-64-to-32, how I know implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32_t ' (aka ' int ') warning is the-wno-shorten-64-to-32 type? Here, in fact, do not need to remember, when the project has this type of warning when
In the warning window, on a warning, we right-click, display the right-click menu, select the Reveal in Log

It will show
Notice that [-wshorten-64-to-32], in this parenthesis, is the type of this warning-W is the prefix, this prefix indicates the warning to open this type if we are to turn off some type of warning, we want to switch-W to-wno-so that we get the-wno-sho It's rten-64-to-32.


PostScript: For third parties we use cocoapod to introduce, we can add a sentence in the Podfile fileinhibit_all_warnings! come to the pod of the project does not show any warning,For exampleLink_with ' Secondhousebrokerapp ',' secondhousebrokercom '
Platform:ios,' 6.0 '
inhibit_all_warnings!


Pod ' Cocoaasyncsocket '
Pod ' reachability '
Pod ' PROTOBUFOBJC '
Pod ' Sdwebimage '
Pod ' FMDB '
Pod ' Gpuimage '
Pod ' Cxphotobrowser 'pod ' cocoalumberjack '
Also, the above method is suitable for other types of warnings!!!
Reference Http://oleb.net/blog/2013/04/compiler-warnings-for-objective-c-developers/http://amattn.com/p/better_apps_ clang_weverything_or_wall_is_a_lie.htmlhttp://stackoverflow.com/questions/16384530/ clang-in-xcode-start-with-weverything-and-manually-disable-particular-warninhttp://adoptioncurve.net/archives/ 2013/02/selectively-disabling-warnings-with-xcode-compiler-flags/

How to remove some type of warning from the Xcode project implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32

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.