The most accepted answer by bsruth on this page using __cpuid loops unnecessarily through not needed extended functions.
If all you need to know is the Processor Brand String then there is no need to query 0x80000000.
Wikipedia has a nice explanation with example code:
https://en.wikipedia.org/wiki/CPUID#EAX=80000002h,80000003h,80000004h:_Processor_Brand_String
#include <cpuid.h> // GCC-provided
#include <stdio.h>
#include <stdint.h>
int main(void) {
uint32_t brand[12];
if (!__get_cpuid_max(0x80000004, NULL)) {
fprintf(stderr, "Feature not implemented.");
return 2;
}
__get_cpuid(0x80000002, brand+0x0, brand+0x1, brand+0x2, brand+0x3);
__get_cpuid(0x80000003, brand+0x4, brand+0x5, brand+0x6, brand+0x7);
__get_cpuid(0x80000004, brand+0x8, brand+0x9, brand+0xa, brand+0xb);
printf("Brand: %s\n", brand);
}
and here is the version i came up with to directly convert it to a std::string in c++
std::string CPUBrandString;
CPUBrandString.resize(49);
uint *CPUInfo = reinterpret_cast<uint*>(CPUBrandString.data());
for (uint i=0; i<3; i++)
__cpuid(0x80000002+i, CPUInfo[i*4+0], CPUInfo[i*4+1], CPUInfo[i*4+2], CPUInfo[i*4+3]);
CPUBrandString.assign(CPUBrandString.data()); // correct null terminator
std::cout << CPUBrandString << std::endl;
this version is for linux, but it shouldn't be too hard to figure out for windows using __cpuid