【发布时间】:2013-04-17 17:13:15
【问题描述】:
环境
XCode 4.6.2
OSX 10.7.5
NMFoo.h
typedef void(^NMFooBlock)();
struct NMFooStruct {
__unsafe_unretained NMFooBlock fooBlock;
};
typedef struct NMFooStruct NMFooStruct;
@interface NMFoo : NSObject
@end
NMFoo.m
#import "NMFoo.h"
NMFooBlock const NMFooBlockConst = ^{};
NMFooStruct const NMFooStructConst = { .fooBlock = NMFooBlockConst };
@implementation NMFoo
@end
产生一个
错误:初始化元素不是编译时常量 NMFooStruct const NMFooStructConst = { .fooBlock = NMFooBlockConst };
即使 NMFooBlockConst 被定义为 const,这是预期的行为吗?
【问题讨论】:
-
肯定是 1. 不是“联系人”而是常数,2. 这与 Xcode 无关。
标签: objective-c xcode struct constants clang