How to programmatically get the CPU cache page size in C++?

Solution 1:

On Win32, GetLogicalProcessorInformation will give you back a SYSTEM_LOGICAL_PROCESSOR_INFORMATION which contains a CACHE_DESCRIPTOR, which has the information you need.

Solution 2:

On Linux try the proccpuinfo library, an architecture independent C API for reading /proc/cpuinfo