' Nsinteger ' (aka ' Long ') to ' int32

Source: Internet
Author: User

How to remove some type of warning from the Xcode project implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32Problem 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 remove the warning?  1. The most direct, one-time, safest way to directly find the warning code, instead of warning. This is the safest way to do it. 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 is possible to update at any time, we this way, obviously not very desirable.  2. Use the compiler-provided macros to manipulate the This way in our project will be a lot of see #pragma clang diagnostic push#pragma clang diagnostic ignored "-wdeprecated-declarations"                //written in this middle of the code, will not be prompted by the compiler-wdeprecated-declarations type of warning Dispatch_queue_ Tcurrentqueue =dispatch_get_current_queue (); #pragma clang diagnostic pop  The problem of this way, similar to the first one, is to modify the implementation of the source code, for third parties, We certainly do not want to change it, especially some update very frequent third-party, the general warning appears shortly after the author updated, we do this in this operation, it seems wasteful. And when adding arm64 support, there are hundreds of of some types of warnings, it is also very time-consuming and laborious to change it! such as our project, opened the arm64, and then compiled   3. To close a warning of a specified type of 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 a certain type of warning for a specified file, as if we had added an arc support to a file or did not support it by adding ignore/show a type warning double-click the file, add  -wno-shorten-64-to-32   ( The key is to let the compiler ignore ImpliciT conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32_t ' (aka ' int ') warning) after the addition is complete and then compiled, then the Presencepacket file  implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') to ' int32_t ' (aka ' int ') warning is not, is not very simple, very convenient. &NB sp;   this way, has greatly reduced the workload, just 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 entire project Specifies the type of warning?  4. To dismiss a warning of a specified type in a project this is the simplest, the project target has an other Warning Flags (search in the right search box after the item is selected) in which to add  - wno-shorten-64-to-32 re-compile, haha, the entire file   implicit conversion loses integer precision: ' Nsinteger ' (aka ' Long ') To ' int32_t ' (aka ' int ') WARNING all disappeared!!!!   5. Everyone may be wondering how the above-wno-shorten-64-to-32 is coming, how do 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, does not need to remember, When the project has this type of warning   in the warning window, a warning, we right-click, display the right-click menu, select the Reveal in log  will show   notice where [-wshorten-64-to-32], In this parenthesis is the type of the warning  -W is the prefix, this prefix indicates the warning to open this type if we are going to turn off some type of warning, we will-W Change to-wno-  this gets  -wno-shorten-64-to-32. .    PostScript: For the third party we use Cocoapod to introduce, we can add a sentence in the Podfile file   inhibit_all_warnings! The project to get the pod does not show any warnings, such as link_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 method above is also 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/

' 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.