2011-08-01 6 views
1

MAC에서 런타임시 프로세스 아키텍처를 찾는 방법이 있습니까?런타임시 CPU 아키텍처

32 비트는 sizeof(int) == 4이고 64 비트는 sizeof(int) == 8입니다. 우아한 방법이 있습니까?

+0

NSBundle의. 어디서나 데이터를 전송하고 있습니까? –

+2

OS X을 겨냥하고 있다면, 'sizeof' 연산자에 의존하지 않고 쿼리 할 수있는 기능을 가지고 있다고 확신합니다. ('sizeof'는 * 컴파일 타임 * 상수입니까? 어떤 경우에는 더 적합한 CPP 정의가 있다고 생각합니다) –

+0

다중 아키텍처 바이너리를 사용하고 있다고 가정합니까? –

답변

0

사용 @property(readonly) NSInteger executableArchitecture와 상수 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"); 
}