English 中文(简体)
System Architecture
原标题:

How do I determine whether the currently running Mac OS X system is of 32bit or 64bit machine?

问题回答

It depends on what you mean by "64 bit machine". There are broadly three categories depending on processor family:

  1. Supports some 64-bit math operations
  2. Can run programs in X-64 mode (64-bit addressing)
  3. Has 64-bit kernel support

I assume that you mean sense "2" here, since that s the most relevant for application code. You don t have to worry about sense "1" unless you need to run on older PowerPC Macs, I believe.

You specifically mentioned doing this in C code, which doesn t actually make much sense. If you re compiling C code, you can just build your application "fat", with 32- and 64- bit variants, and therefore do the check at compile-time with:

#if _LP64
//64-bit stuff
#else
//32-bit stuff
#endif

I m fairly certain that sizeof(long) == 4 on 32-bit systems and sizeof(long) == 8 on 64-bit systems. The same should be true of pointers.

a little greppy, but ..

#!/bin/sh

ioreg -l -p IODeviceTree | grep EFI64
if [ $? = 0 ]
then
    echo "I am a 64bit machine!"
else 
    echo "I am a 32bit machine!"
fi

wrapped in an NSTask *task = [[NSTask alloc] init]; ...?





相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签