Nat! bio photo

Nat!

Senior Mull

Twitter Github Twitch

MACOSX_DEPLOYMENT_TARGET is no safe bet ?

I naively thought, that when I compile to a 10.6 target, features that are new starting from 10.7 would not appear ? Wrong.

$ cat foo.m
#import <Foundation/Foundation.h>


int   main(int argc, const char * argv[])
{
   NSLog( @"%p", [NSNumber numberWithInt:argc]);
   NSLog( @"%p", [NSNumber numberWithLongLong:LONG_LONG_MAX]);
   return 0;
}
$ clang -x objective-c -arch x86_64 -mmacosx-version-min=10.4 -g -framework Foundation -o foo foo.m ; ./foo
2015-04-17 21:05:54.280 foo[42262:507] 0x127
2015-04-17 21:05:54.284 foo[42262:507] 0x1003007e0

The first number is clearly a tagged pointer, whereas the other isn’t.

If it helps: i386 is too small for tagged pointers. If you need to check for tagged pointers in your code, you are better off checking against __LP64__ then MAC_OS_X_VERSION_MIN_REQUIRED or some such.


Post a comment

All comments are held for moderation; basic HTML formatting accepted.

Name:
E-mail: (not published)
Website: