Is there a way to determine how many cores a machine has from C/C++ in a platform-independent way? If no such thing exists, what about determining it per-platform (Windows/*
More on OS X: sysconf(_SC_NPROCESSORS_ONLN) is available only versions >= 10.5, not 10.4.
sysconf(_SC_NPROCESSORS_ONLN)
An alternative is the HW_AVAILCPU/sysctl() BSD code which is available on versions >= 10.2.
HW_AVAILCPU/sysctl()