I have some portability issues when I mix ARC with some occasional manual 
retains (especially when hand writing encoders and decoders).

The offending function is CFRetain and CFRelease, which is, as documented by 
Apple, recommended as replacements of (forbidden by ARC) -[NSObject retain] and 
-[NSObject release] methods.

However due to the structural difference of GNUstep libraries, the 
aforementioned two functions are missing.

Currently I resort to conditionally compiled inline function wrappers (same 
name and signature, different implementation) to handle this issue, as done in 
the following code snippet (extracted from ohttpd2 project, 2-clause BSDL 
licensed, hosted at https://github.com/xcvista/ohttpd2):

#ifdef     GNUSTEP

#import <objc/objc_arc.h>

static inline id CGIRetain(id obj)
{
    return objc_retain(obj);
}

static inline void CGIRelease(id obj)
{
    objc_release(obj);
}

#else   // GNUSTEP

#import <CoreFoundation/CoreFoundation.h>

static inline id CGIRetain(id obj)
{
    return (__bridge id)CFRetain((__bridge CFTypeRef)obj);
}

static inline void CGIRelease(id obj)
{
    CFRelease((__bridge CFTypeRef)obj);
}

#endif  // GNUSTEP

If you can move the aforementioned methods from CoreBase to Base, this 
portability issue can be addressed.

Max
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to