Created
September 14, 2012 23:08
-
-
Save 0xced/3725528 to your computer and use it in GitHub Desktop.
Weak linking with extern NSString *const issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Social/Social.h> | |
/* Compiled with iOS 6 SDK | |
* Social.framework weak linked (Optional) | |
* Run on iOS 5.1 (simulator and device) | |
* Output is: | |
* 0x0 | |
* About to crash | |
* +++ EXC_BAD_ACCESS +++ | |
*/ | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool | |
{ | |
NSLog(@"%p", &SLServiceTypeFacebook); | |
if (&SLServiceTypeFacebook) | |
{ | |
NSLog(@"About to crash"); | |
NSString *serviceType = SLServiceTypeFacebook; // crashes here with EXC_BAD_ACCESS (code=2, address=0x0) | |
NSLog(@"Not reached %@", serviceType); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Checking for Weak Linked Frameworks, Checking the address of a weak lInked symbol under LLVM not working as expected and Checking for symbols in weakly linked frameworks shouldn't get optimized out for workarounds.