|
From: | Stefan Bidigaray |
Subject: | Re: CoreBase and ARC |
Date: | Thu, 19 Feb 2015 11:07:35 -0600 |
I would appreciate if David C. could confirm that this is the correct solution before committing, though.So when CoreBase first came around ARC was at it's infancy and being able to seemingly go from CF to ObjC objects was a good idea. All the "toll-free bridged" types have a construct similar to:The obvious compatibility solution here would be to get rid of those #ifdef's and always define CF types to be typedef struct ...#ifdef __OBJC__ @class NSData; @class NSMutableData; typedef NSData* CFDataRef; typedef NSMutableData* CFMutableDataRef; #else typedef const struct __CFData * CFDataRef; typedef struct __CFData * CFMutableDataRef; #endifThis is very handy, but after doing some research on ARC it requires explicit transferring control to C because ARC cannot keep up with what's going on in C structs. See https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html if you're interested in the details.On Tue, Feb 17, 2015 at 11:25 AM, Maxthon Chan <xcvista@me.com> wrote:I am getting a bit of trouble compiling code with CoreBase and ARC at the same time. I am using latest trunk version of base and corebase on Ubuntu 14.04 LTS with clang 3.5. Here is the log:
$ make
This is gnustep-make 2.6.6. Type 'make print-gnustep-make-help' for help.
Making build-headers for framework CGIKit...
Creating CGIKit.framework/Versions/H/Headers...
Creating derived_src/.stamp...
Creating CGIKit.framework/Versions/H/Resources...
Updating Version/Current symlink...
Making all for framework CGIKit...
Compiling file CGIApplication.m ...
In file included from CGIApplication.m:9:
In file included from ./CGIApplication.h:12:
In file included from ../CGIKit/CGIKitDefines.h:51:
In file included from /usr/local/include/GNUstep/CoreFoundation/CoreFoundation.h:36:
In file included from /usr/local/include/GNUstep/CoreFoundation/CFBundle.h:31:
In file included from /usr/local/include/GNUstep/CoreFoundation/CFURL.h:34:
/usr/local/include/GNUstep/CoreFoundation/CFString.h:538:15: error: ARC forbids Objective-C objects in struct
CFStringRef theString;
^
In file included from CGIApplication.m:9:
In file included from ./CGIApplication.h:12:
In file included from ../CGIKit/CGIKitDefines.h:51:
In file included from /usr/local/include/GNUstep/CoreFoundation/CoreFoundation.h:48:
In file included from /usr/local/include/GNUstep/CoreFoundation/CFPropertyList.h:33:
In file included from /usr/local/include/GNUstep/CoreFoundation/CFStream.h:33:
/usr/local/include/GNUstep/CoreFoundation/CFSocket.h:61:13: error: ARC forbids Objective-C objects in struct
CFDataRef address;
^
In file included from CGIApplication.m:9:
In file included from ./CGIApplication.h:12:
In file included from ../CGIKit/CGIKitDefines.h:51:
In file included from /usr/local/include/GNUstep/CoreFoundation/CoreFoundation.h:60:
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:76:12: error: ARC forbids Objective-C objects in struct
CFURLRef systemID;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:83:15: error: ARC forbids Objective-C objects in struct
CFStringRef attributeName;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:98:12: error: ARC forbids Objective-C objects in struct
CFURLRef sourceURL;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:111:19: error: ARC forbids Objective-C objects in struct
CFDictionaryRef attributes;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:119:15: error: ARC forbids Objective-C objects in struct
CFStringRef contentDescription;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:126:15: error: ARC forbids Objective-C objects in struct
CFStringRef replacementText;
^
/usr/local/include/GNUstep/CoreFoundation/CFXMLNode.h:146:15: error: ARC forbids Objective-C objects in struct
CFStringRef dataString;
^
CGIApplication.m:30:65: error: expected method body
- (instancetype)_init __attribute__((objc_method_family(init))) NS_REPLACES_RECEIVER
^
10 errors generated.
make[2]: *** [obj/CGIKit.obj/CGIApplication.m.o] Error 1
make[1]: *** [internal-framework-run-compile-submake] Error 2
make: *** [CGIKit.all.framework.variables] Error 2
And then I got this trying to check for “pesky typedefs":
$ clang -E $(gnustep-config --objc-flags) -fobjc-arc -I. -I.. CGIApplication.m
// … lines removed …
# 268 "/usr/local/include/GNUstep/CoreFoundation/CFBase.h"
typedef CFTypeRef CFPropertyListRef;
@class NSString;
@class NSMutableString;
typedef NSString * CFStringRef;
typedef NSMutableString * CFMutableStringRef;
# 294 "/usr/local/include/GNUstep/CoreFoundation/CFBase.h"
typedef const struct __CFAllocator * CFAllocatorRef;
typedef void* (*CFAllocatorAllocateCallBack)(CFIndex allocSize,
CFOptionFlags hint, void *info);
// … lines removed …
The typedef here works “seemingly” well without ARC but it bites me in the ass when ARC is used.
Does this call for a change? How to do it?
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
[Prev in Thread] | Current Thread | [Next in Thread] |