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/*
One more Windows recipe: use system-wide environment variable NUMBER_OF_PROCESSORS:
NUMBER_OF_PROCESSORS
printf("%d\n", atoi(getenv("NUMBER_OF_PROCESSORS")));