如何知道当前架构是mac中的i386还是x86_64?(Xcode中)

nac*_*o4d 5 macos xcode objective-c

我正在处理一个在不同架构中需要不同参数的相机,是否有一个标志我可以检查我的mac是32位还是64位?我试过这个但似乎不起作用,我总是得到32位!:

#if defined(PER_ARCH_CFLAGS_x86_64)
    NSLog(@"64bit!!");
#else 
    NSLog(@"32Bits!!");
#endif  
Run Code Online (Sandbox Code Playgroud)

小智 8

#ifdef __x86_64__
  //64-bit intel
#endif
#ifdef __i386__
  //32-bit intel
#endif
//carry on for ppc, ppc64, ARM
Run Code Online (Sandbox Code Playgroud)

要么...

#ifdef __LP64__
  //64-bit Intel or PPC
#else
  //32-bit Intel, PPC or ARM
#endif
Run Code Online (Sandbox Code Playgroud)