标签:style blog http color os io ar div
//测试CPU核心个数 #if !defined (_WIN32) && !defined (_WIN64) #define LINUX #include <unistd.h> #else #define WINDOWS #include <windows.h> #endif unsigned core_count() { unsigned count = 1; // 至少一个 #if defined (LINUX) count = sysconf(_SC_NPROCESSORS_CONF); #elif defined (WINDOWS) SYSTEM_INFO si; GetSystemInfo(&si); count = si.dwNumberOfProcessors; #endif return count; } #include <iostream> int main() { unsigned sz = core_count(); std::cout << sz << (1 == sz ? "core" : "cores") << std::endl; }
http://www.cppblog.com/Chipset/archive/2009/02/20/74403.html
标签:style blog http color os io ar div
原文地址:http://www.cnblogs.com/youngt/p/3926759.html