refactoring #ifndef
I'm writing an app in an ARC environment, and I'm trying to use a 3rd party library that was written before ARC. I'm using the -fno-objc-arc flags on all the relevant files, so it's compiling, but the project uses #ifndef __OBJC_GC_ blocks to release memory, which is causing memory allocation errors. I'm trying to determine the right solution, and so far I have the following:
1.) find a different library or write my own - this is the only free library of it's kind, so this is obviously not ideal, and I'm new enough that I don't feel comfortable tackling that
2.) remove the #ifndef blocks and cross my fingers - not able to work on the project today, but that's my next plan
3.) refactor the code to be ARC compliant and remove the -fno-objc-arc flags
is #2 likely to work? How hard would #3 be, andwould it actually cause the compiler to define __OBJC_GC_? (there's about 4-5 classes that I'm planning on using, but they're pretty sizeable)
You say the allocation blocks are enclosed into #ifndef __OBJC_GC_
. Note it is #ifndef
- "if not defined".
So it should work out of the box if the author maintains the non-GC version correctly. There is no need for you to remove ifdefs or to forge them.
The compiler, even with ARC on, should not define this flag for iOS. Just make sure the library itself does not set this flag explicitly..
我建议考虑另一个选项:关闭项目的ARC。
链接地址: http://www.djcxy.com/p/72760.html上一篇: 释放不会引起错误
下一篇: 重构#ifndef