Initializer element is not a compile-time constant - Referring a const block from a const struct


XCode 4.6.2 OSX 10.7.5


typedef void(^NMFooBlock)();

struct NMFooStruct {
    __unsafe_unretained NMFooBlock fooBlock;
typedef struct NMFooStruct NMFooStruct;

@interface NMFoo : NSObject



#import "NMFoo.h"

NMFooBlock const NMFooBlockConst = ^{};

NMFooStruct const NMFooStructConst = { .fooBlock = NMFooBlockConst };

@implementation NMFoo


yields a

error: initializer element is not a compile-time constant NMFooStruct const NMFooStructConst = { .fooBlock = NMFooBlockConst };

Is that the expected behaviour even though NMFooBlockConst is defined as const?


The answer lies here, I think:

However, this will work:

NMFooStruct const NMFooStructConst = { .fooBlock = ^{} };

Need Your Help

adding an element to JSON Array JavaScript

javascript arrays json

I have the following array in my source code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.