小积累
windows
#include <windows.h>
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
int num_cpu = sysInfo.dwNumberOfProcessors;
linux
#include <unistd.h>
int num_cpu = sysconf( _SC_NPROCESSORS_CONF);
跨平台
宏
小积累
windows
#include <windows.h>
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
int num_cpu = sysInfo.dwNumberOfProcessors;
linux
#include <unistd.h>
int num_cpu = sysconf( _SC_NPROCESSORS_CONF);
跨平台
宏