The single thing that worked for me is to use gcc
with its `__builtin_cpu_supports feature`. 
Since I invoked it in msys it is likely to work on Windows too. 
Can be done with C++ too.

 // test_cpu.c
 #if defined(__clang__) || !defined(__GNUC__)
 #error "You must use gnu"
 #endif
 
 #include <stdio.h>
 int main() {
 if (__builtin_cpu_supports("x86-64-v4")) {
 printf("v=%d", 4);
 } else if (__builtin_cpu_supports("x86-64-v3")) {
 printf("v=%d", 3);
 } else if (__builtin_cpu_supports("x86-64-v2")) {
 printf("v=%d", 2);
 } else {
 printf("v=%d", 1);
 }
 }

Usage:
```
$ gcc /test_cpu.c -o /test_cpu

$ /test_cpu
v=3
```