[cfe-dev] objc++ enhancements for new c++ features

James Gregurich via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 29 11:31:55 PDT 2018



> 
> The functions used by ARC are simple C functions.  If you are willing to assume a runtime that supports ARC, then you can simply call objc_retain / objc_release explicitly when compiling with a non-ARC ObjC++ compiler.  
 
I'm aware of that and I make use of it in my workaround. That isn't the issue. I shouldn't need to do play that game. the tool chain should do the right thing out of the box whether or not ARC is enabled.


> I did this years ago to have code that worked with ARC and non-ARC ObjC++.  If you are not willing to assume an ARC-enabled runtime, then you will need a wrapper with a separate reference count to get weak pointers, because the classical retain / release mechanism doesn’t provide the required synchronisation.
> 
> David
> 


exactly my point.  if I'm going to do that, then I would be just re-implementing what shared_ptr and weak_ptr already do. that would be pointless.


BTW. our codebase is mainly NON-arc with one ARC stepchild.  I would get rid of ARC if I could because it imposes its own problems that I hate dealing with...but that isn't feasible. I'd never start a new project and use ARC after some experience coding with it.


More information about the cfe-dev mailing list