运行时的CPU体系结构

时间:2011-08-01 18:34:18

标签: macos architecture process

有没有办法在运行时在MAC上找到流程架构?

我使用sizeof(int) == 4表示32位,sizeof(int) == 8表示64位。有优雅的方式吗?

1 个答案:

答案 0 :(得分:0)

使用@property(readonly) NSInteger executableArchitectureNSBundle

的常量Mach-O Architecture
NSInteger architecture = [[NSRunningApplication currentApplication] executableArchitecture];
if(architecture == NSBundleExecutableArchitectureX86_64) {
    NSLog(@"running on 64bits");
else if (architecture == NSBundleExecutableArchitectureI386) {
    NSLog(@"running on 32bits");
} else {
    NSLog(@"running somewhere else");
}