如何在C中测试mac OS版本

时间:2014-09-18 00:00:21

标签: c++ c macos

通常情况下,我会这样做:

SInt32 majorVersion, minorVersion;
Gestalt(gestaltSystemVersionMajor, &majorVersion);
Gestalt(gestaltSystemVersionMinor, &minorVersion);

bool is106 = majorVersion == 10 && minorVersion <= 6;

但不推荐使用Gestalt

我在obj-C中使用sysctloperatingSystemVersionString找到了各种解决方案。 新的文档方式是使用NSAppKitVersionNumber,但我的代码没有链接到AppKit(并且是在C ++中)

我需要一个简单的C / C ++,非弃用的方法。我找不到一个:(

修改:根据此文档:https://developer.apple.com/library/mac/releasenotes/General/CarbonCoreDeprecations/index.html#//apple_ref/doc/uid/TP40012224-CH1-SW16

使用sysctl是现在的官方方式

0 个答案:

没有答案
相关问题