我有一段C ++代码库已经存在了一段时间(10年以上)并且它编译并运行良好,但我注意到当我在OS / X 10.8.x(Mountain Lion)下编译它时,编译器会发出关于它所调用的一些Carbon函数的弃用警告:
../system/SetupSystem.cpp:575:44: warning: 'UpTime' is deprecated: first
deprecated in OS X 10.8 [-Wdeprecated-declarations]
../system/SetupSystem.cpp:575:22: warning: 'AbsoluteToNanoseconds' is
deprecated: first deprecated in OS X 10.8 [-Wdeprecated-declarations]
../system/SystemInfo.cpp:249:25: warning: 'MPProcessors' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
我想将此代码库升级到Apple批准的新方式(因此,如果/当Apple最终删除这些功能时避免警告和未来的痛苦),但我无法弄清楚新的标准是。我查看了developer.apple.com上的OS / X文档,但是我的搜索技能缺乏或者他们的文档都没有,因为我几乎找不到这些函数,也没有关于它们的替换。
我有具体问题:
答案 0 :(得分:2)
我找到了上面列出的功能的可用替代品:
#include <mach/mach_host.h> mach_msg_type_number_t infoCount = HOST_BASIC_INFO_COUNT; host_info(gHostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount); int numProcessors = hostInfo.avail_cpus;