How to tell when app will run in 64-bit mode?

Ben Allison benski at winamp.com
Wed Feb 6 09:01:35 PST 2008


#ifdef __LP64__
bool in_64bit = true;
#else
bool in_64bit = false;
#endif

More importantly, if you have code that differs between 32bit and 64bit, 
it is better to conditionally compile than it is to check during 
runtime.  Remember that an 'obese-binary' is basically 4 copies of your 
program.

-benski

Jon Gotow wrote:
> Is there a way to determine when an 'obese-binary' application will 
> launch in 64-bit mode?  I'm aware of Apple's CheckExecutableArchitecture 
> sample code
> 
>     http://developer.apple.com/samplecode/CheckExecutableArchitecture/
> 
> but that only distinguishes between Intel and PPC.  My attempts to 
> extend the code to check the cputype flag for x86_64 have been 
> unsuccessful, so I'm wondering if someone's aware of a better way (please?)
> 
>  - Jon
> 



More information about the MacOSX-dev mailing list