ios - __strong qualifier used in non ARC project -
the project non-arc enabled, (mistakingly) using arc compliant code libraries - 1 create singleton objects defined in gcdsingleton.h:
#define define_shared_instance + (id)sharedinstance { static dispatch_once_t pred = 0; __strong static id _sharedobject = nil; dispatch_once(&pred, ^{ _sharedobject = ^{return [[self alloc] init];}(); }); return _sharedobject; }
this seems work though shared object defined __strong qualifier. i'm wondering why doesn't cause error or @ least warning (latest xcode 4.6 , ios 6 sdk). also, since project not arc enabled, __strong qualifier doing, if anything?
in mrc code, __strong
ignored.
i tried compile simple example
#import <foundation/foundation.h> int main(int argc, char const *argv[]) { __strong nsstring * foo = [[nsstring alloc] initwithformat:@"hello, %s", argv[1]]; nslog(@"%@", foo); }
with arc
clang -fobjc-arc test.m -s -emit-llvm -o arc.ir
and without arc
clang -fno-objc-arc test.m -s -emit-llvm -o mrc.ir
and diff llvm ir output.
here's result of diff mrc.ir arc.ir
54a55,56 > %17 = bitcast %0** %foo i8** > call void @objc_storestrong(i8** %17, i8* null) nounwind 63a66,67 > declare void @objc_storestrong(i8**, i8*) >
so difference between arc , mrc addition of objc_storestrong
call.
by way same code without __strong
qualifier produce same exact results, since __strong
default qualifier variables in arc.
Comments
Post a Comment