clang编译objective-c失败 财富值45

2016-11-01 17:22发布

#import <UIKit/UIKit.h> #import "AppDelegate.h" #import "Person.h"  extern void _objc_autoreleasePoolPrint();  int main(int argc, char * argv[]) {     @autoreleasepool {         Person *p = [Person new];         Person __weak *p2 = p;         NSLog(@"%@", p2);         _objc_autoreleasePoolPrint(); //        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));     } }

结果是这样的:

$ clang -rewrite-objc -fobjc-arc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk main.m /var/folders/t0/nty3j9vx1rn8786q_tpclydc0000gn/T/main-2fe2fd.mi:46509:31: error: cannot create __weak reference       because the current deployment target does not support weak references         Person __attribute__((objc_ownership(weak))) *p2 = p;                               ^ 1 error generated.

求解答

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答

__Weak不是应该在类名前面吗?

一周热门 更多>