Arc chaos in c header files in ios

Source: Internet
Author: User

The problem is a bit strange. Let me describe it in detail. I created a c header file FALog. hL as my log tool class (non-arc) instead of NSLog. This c file contains part of the objc code. My entire project is non-arc and only two files A and B are arc. In build parses, I set compile flags of A and B to-fobjc-arc, before I add files A and B, my FALog can be compiled normally. After adding files A and B, in FALog, my release and autorelease always prompt "release is not allowed under arc", as shown below: [cpp] 'autorelease 'is unavailable: not available in automatic reference counting mode the problem is that my FALog is really not an arc, and it's crazy. The final solution is fruitless. I decided to check if my falog is true of arc and use the macro: [cpp] # if _ has_feature (objc_arc) // ARC is On # else // ARC is Off # endif it turns out that my falog is non-arc and speechless, So I add macro judgment before and after my release code, [html] # if! (_ Has_feature (objc_arc) NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelter]; # endif is compiled successfully. I am speechless and it is not arc, now, let me determine if arc can be compiled successfully. I don't know what's going on with xcode. It has been bothering me for n days. I hope it will help you. In addition, if the arc and non-arc files are mixed in ios, you can specify compile flags in build parses. If the arc file is set to "-fobjc-arc ", non-arc file is set to "-fno-objc-arc"

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.