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

Environment

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

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?

Answers


The answer lies here, I think: http://stackoverflow.com/a/6143271/73479

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.