NSLog(@"size int:%d", sizeof(int));
NSLog(@"size NSInteger:%d", sizeof(NSInteger));
NSLog(@"size long:%d", sizeof(long));
NSLog(@"size long long:%d", sizeof(long long));
64位手机打印:
2022-07-01 15:10:28.637665+0800 PodDemo[88791:3552265] size int:4
2022-07-01 15:10:28.637776+0800 PodDemo[88791:3552265] size NSInteger:8
2022-07-01 15:10:28.637809+0800 PodDemo[88791:3552265] size long:8
2022-07-01 15:10:28.637838+0800 PodDemo[88791:3552265] size long long:8
#if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
编写跨平台需要注意长度的问题。
网友评论