> On 10 Aug 2015, at 13:21, Roland King <r...@rols.org> wrote: > > >> On 10 Aug 2015, at 19:59, Dave <d...@looktowindward.com >> <mailto:d...@looktowindward.com>> wrote: >> >> Hi, >> >> Has anyone come up with a way of having the source code support both ARC and >> Manual Memory Management without using #IFDEF or #IF ? >> >> I’ve never understood why the compiler doesn’t just ignore code like: >> >> [super dealloc]; >> >> [MyObj release]; >> >> If it’s being compiled for ARC, that way both could be compiled with the >> same source code or is there more to it? >> >> > > What’s the use case here? ARC and MMR are completely interoperable. When > would you need to compile a file under both? If it’s legacy and needs to > build under a really old compiler then you don’t convert it to ARC and you > always compile it non-ARC, once it’s converted you always compile it with ARC > no matter what you’re doing for other files in the project. > > As for why - the rationale is in section 7.1.1 of the arc spec > http://clang.llvm.org/docs/AutomaticReferenceCounting.html > <http://clang.llvm.org/docs/AutomaticReferenceCounting.html> and the > following section for dealloc. It’s specified that code is ill-formed if it > includes any of those and so the compiler has to follow the spec to it can’t > ignore them. You may or may not agree with the rationale, but at least the > specifiers of the language did write down why it’s that way.
That’s fair enough, I was wondering if there was any deep reason. The thing is I have library classes that I use in older projects that are non-ARC, I was trying avoid having two sets of more or less identical files. I preprocessor that removes them if the project is ARC might work, but I guess it would probably confuse the debugger. I saw it done horribly once, where instead of calling [super dealloc]; it used [super Dealloc]; and [myObject Release]; and then defined these methods as a category on NSObject. I really don’t fancy doing that. Cheers Dave _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com