What to do about Carbon functions that are deprecated in MacOS/X 10.8.x?

回眸只為那壹抹淺笑 提交于 2019-12-04 07:31:07
Jeremy Friesner

I've found usable replacements for the functions listed above:

  1. UpTime() can be replaced by a call to mach_absolute_time(), as detailed here.
  2. AbsoluteToNanoseconds() can be replaced by a bit of math, as shown at the above link.
  3. MPProcessors can be replaced by a call to host_info(), like this:
#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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!