) How to remove some warning Implicit conversion loses integer precision: & #39; NSInteger & #39; (aka & #39; long & #39 ;) to & #39; int32, implicitconversion

Source: Internet
Author: User

(Switch) how to remove some type of warning in Xcode project Implicit conversion loses integer precision: 'nsinteger '(aka 'long') to 'int32, implicitconversion
Problem description in our project, we usually use a large number 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 or compiler is upgraded, there may be many warnings for these legacy codes. Is there a way to remove these annoying warnings? Otherwise, there may be hundreds of warnings for a project, why are you upset. how can we remove the warning? 1. the most direct, permanent, and secure method is to directly find the warning code, instead of warning. this method is the safest. but it has a problem: when many of our files have this type of warning, we need to change a lot of source code. For the source code that is not written by us, it may be updated at any time. Obviously, this method is not desirable. 2. use the macro provided by the compiler for operations. This method will be seen in a lot in our project # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wdeprecated-declarations "// The code written in the middle won't be prompted by the compiler-Wdeprecated-declarations warning dispatch_queue_tcurrentQueue = dispatch_get_current_queue (); # pragma clang diagnostic pop, which is similar to the first one, it is also necessary to modify the source code implementation. for third parties, we certainly do not want to modify it, especially for some third parties with frequent updates. The author will update it shortly after the warning appears, this operation is a waste of resources. when adding the support for arm64, there are hundreds of warnings of some type, which is quite time-consuming and labor-consuming! For example, in our project, we open arm64 and then compile 3. to close the warning of a specified type of a specified file, take a specific project as an example. for example, in our project, there is a file PresencePacket. In fact, it is very easy to disable some type of warning for a specified file, just as if we used to add ARC support or not support to a file, we added ignore/display a type of warning double-click File, add-Wno-shorten-64-to-32 in it (the key is to let the compiler ignore Implicit conversion loses integer precision: 'nsinteger '(aka 'long') to 'int32 _ t' (aka 'int ') warning) after adding the package, compile it again. The Implicit conversion loses integer precision in the PresencePacket file: 'nsinteger '(aka 'Long') To 'int32 _ t' (aka 'int'), there is no warning. Is it very simple and convenient. this method has greatly reduced the workload, just need to add-Wno-shorten-64-to-32 In the compilation of the specified file. is there any way for the compiler to ignore the specified type of warning in the entire project? 4. it's easiest to close the Warning of the specified type in the project, and the target of the project has an Other Warning Flags in it to add-Wno-shorten-64-to-32 and re-compile, haha, Implicit conversion loses integer precision in the entire file: 'nsinteger '(aka 'long') to 'int32 _ t' (aka 'int') Warning All disappears !!!! 5. you may be wondering how the above-Wno-shorten-64-to-32 came from, how do I know Implicit conversion loses integer precision: 'nsinteger '(aka 'long ') to 'int32 _ t' (aka 'int') Warning is-Wno-shorten-64-to-32 type? In fact, there is no need to remember this. When there is such a type of warning in the project, in the warning window, on a warning, we right-click and display the right-click menu, when Reveal in Log is selected, it is displayed that notice where [-Wshorten-64-to-32], in which the type of this warning in parentheses-W is the prefix, this prefix indicates opening this type of warning. If we want to close some type of warning, we need to replace-W with-Wno-so that we can get-Wno-shorten-64-to-32. note: For third parties we introduced using cocoapod, we can add an inhibit_all_warnings in the podfile file! The project to be pod does not display any warning, 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'. The above method is also suitable for other types of warnings !!!

Related Article

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.