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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3297842/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:33:46  来源:igfitidea点击:

how to know if current architecture is i386 or x86_64 in macs? (Xcode)

objective-cxcodemacos

提问by nacho4d

I am handling a camera that needs different parameters in different architecture, Is there a flag that I can check to see if I am in 32bits or 64bits in my mac? I was trying this but does not seem to work, I always get 32Bits!! :

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

#if defined(PER_ARCH_CFLAGS_x86_64)
    NSLog(@"64bit!!");
#else 
    NSLog(@"32Bits!!");
#endif  

回答by

#ifdef __x86_64__
  //64-bit intel
#endif
#ifdef __i386__
  //32-bit intel
#endif
//carry on for ppc, ppc64, ARM

or...

或者...

#ifdef __LP64__
  //64-bit Intel or PPC
#else
  //32-bit Intel, PPC or ARM
#endif