The cpuid instruction recently caught my interest and I decided to write a library libicuid that gathers and decodes all the information it outputs. It provides a C interface that is compatible with C++ programs, is written in C and Assembly, and supports all major compilers GCC, Clang, and Microsoft Visual Studio. I licensed it under the ISC License which is functionally equivalent to the BSD 2-Clause License. You can visit its homepage here.

Example C program code:

#include <stdio.h>
#include <icuid/icuid.h>

int main(int argc, char **argv)
{
    int ret = -1;
    cpuid_raw_data_t raw;
    cpuid_data_t data;

    ret = cpuid_get_raw_data(&raw);
    if (ret != ICUID_OK) {
        printf("%s\n", icuid_errorstr(ret));
        return ret;
    }

    ret = icuid_identify(&raw, &data);
    if (ret != ICUID_OK) {
        printf("%s\n", icuid_errorstr(ret));
        return ret;
    }

    printf("Vendor: %s\n", data.vendor_str);
    printf("CPU: %s\n", data.brand_str);
    printf("Codename: %s\n", data.codename);
    printf("Cores: %u\n", data.cores);
    printf("Logical: %u\n", data.logical_cpus);

   if (data.flags[CPU_FEATURE_AVX])
       printf("CPU Supports AVX\n");

   return ret;
}