mtlpp icon indicating copy to clipboard operation
mtlpp copied to clipboard

No ARC support

Open DevNulPavel opened this issue 7 years ago • 1 comments

Autorelease method included for allocated objects

DevNulPavel avatar Jan 24 '18 09:01 DevNulPavel

This pull request would make projects using mtlpp not run on 10.12 and later. You can switch to ARC in your codebase and still support 10.6 and later + iOS 4 and later

Any Objective C code that manually calls autorelease uses Objective C Garbage Collection which has been deprecated on Mac since 10.8

ARC is the new way to manage memory since 10.6 and iOS4 Full details are here: https://developer.apple.com/library/archive/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

  • You cannot explicitly invoke dealloc, or implement or invoke retain, release, retainCount, or autorelease.

  • You may implement a dealloc method if you need to manage resources other than releasing instance variables.

    • Custom dealloc methods in ARC do not require a call to [super dealloc] (it actually results in a compiler error). The chaining to super is automated and enforced by the compiler.
  • There is no casual casting between id and void *. (This is why mtlpp uses (__bridge void*) instead of (void*) )


Transitioning existing code bases to ARC is often easy

In Xcode's build settings, enable Objective-C Automatic Reference Counting And you can fix most if not all compile errors by removing dealloc, retain, release, retainCount, and autorelease calls from code

This pull request makes the code use autorelease, which depends on Objective-C garbage collection. Objective-C with garbage collection does not compile or run on current versions of Apple's operating systems

Peach1 avatar Jul 04 '18 01:07 Peach1