如何确定Mac OS X 10.6中的内核位数? [英] How to determine kernel bitness in Mac OS X 10.6?

查看:103
本文介绍了如何确定Mac OS X 10.6中的内核位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用terminal和system-profiler命令确定内核的当前位数,但是我正在尝试确定是否有一种方法可以在Objective-C中以编程方式获取相同的信息.

I know that I can use the terminal and the system-profiler command to determine the current bitness of the kernel but I am trying to determine if there is a way to get that same information programmatically in objective-c.

我浏览了Carbon的格式塔,但没有发现任何可以告诉我内核的东西.

I have looked through Carbon's gestalt, but haven't seen anything that would tell me bitness of the kernel.

有人对我该如何做有任何建议吗?对于调试报告,我需要此信息,以便在报告时提供系统快照.

Does anyone have any suggestions as to how I could do this? I need this info for a debugging report that gives a snapshot of the system at the time of the report.

谢谢!

更新:我尝试过的一件事是从Windows世界中学到的一个技巧,就是检查int的大小,例如:

Update: One thing I have tried that is a trick I learned from the Windows world is to check the size of an int like:

sizeof(int*); //(4 = x86 8 = x64)

但是我不认为这是一个解决方案,因为我认为这只会让我了解实际程序本身在运行什么,而不是实际OS内核在运行什么.我的理解是,即使OS内核以32位运行,您的程序仍可以以64位运行.

but I don't think this is a resolution because I think this will only give me an idea of what the actual program itself is running at and not the actual OS kernel. My understanding is that even though the OS kernel is running at 32 bit your program can still run at 64bit.

我在其他论坛上也遇到了与此类似的帖子,但是除了使用system_profiler之外,其他论坛似乎都没有给出答案.

I have run across other forum posting similar to this one but none of them seem to come up with an answer other then using system_profiler.

推荐答案

请参见"i386":

See man 3 uname: It fills a utsname structure which includes a member machine, which is "x86_64" or "i386" on Intel platforms:

struct utsname un;
int res = uname(&un);
if (res >= 0) {
    NSLog(@"%s", un.machine);
}

这篇关于如何确定Mac OS X 10.6中的内核位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆