Skip to main content
deleted 16 characters in body
Source Link

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__) ||#ifndef !defined(__GNUC__) #error "You must use gnu" #endif #include <stdio.h> int main() { if (__builtin_cpu_supports("x86-64-v4")) { printfputs("v=%d", 4"v=4");   } else if (__builtin_cpu_supports("x86-64-v3")) { printfputs("v=%d", 3"v=3");   } else if (__builtin_cpu_supports("x86-64-v2")) { printfputs("v=%d", 2"v=2");   } else { printfputs("v=%d", 1"v=1"); } } 

Usage:

$ gcc /test_cpu.c -o /test_cpu $ /test_cpu v=3 

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 

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 #ifndef __GNUC__ #error "You must use gnu" #endif #include <stdio.h> int main() { if (__builtin_cpu_supports("x86-64-v4")) puts("v=4"); else if (__builtin_cpu_supports("x86-64-v3")) puts("v=3"); else if (__builtin_cpu_supports("x86-64-v2")) puts("v=2"); else puts("v=1"); } 

Usage:

$ gcc /test_cpu.c -o /test_cpu $ /test_cpu v=3 
Improved capitalization, wording, punctuation and formatting.
Source Link

This is theThe single thing that worked for me is to use gcc with it's __builtin_cpu_supports feature with its __builtin_cpu_supports feature. Since i invoked  Since I invoked it in msys it is likely to work on windowsWindows too. Can  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); } } 

Admin@DESKTOP-4DBOBP9 MSYS ~ $ gcc /test_cpu.c -o /test_cpu

Admin@DESKTOP-4DBOBP9 MSYS ~ $ /test_cpuUsage:

v=3

$ gcc /test_cpu.c -o /test_cpu $ /test_cpu v=3 

This is the single thing worked for me is to use gcc with it's __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); } } 

Admin@DESKTOP-4DBOBP9 MSYS ~ $ gcc /test_cpu.c -o /test_cpu

Admin@DESKTOP-4DBOBP9 MSYS ~ $ /test_cpu

v=3

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 
added 4 characters in body
Source Link

This is the single thing worked for me is to use gcc with it's __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); } } 

Admin@DESKTOP-4DBOBP9 MSYS ~ $ gcc /test_cpu.c -o /test_cpu

Admin@DESKTOP-4DBOBP9 MSYS ~ $ /test_cpu

v=3

This is the single thing worked for me is to use gcc with it's __builtin_cpu_supports feature. Since i invoked it in msys it is likely to work on windows. 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); } } 

Admin@DESKTOP-4DBOBP9 MSYS ~ $ gcc /test_cpu.c -o /test_cpu

Admin@DESKTOP-4DBOBP9 MSYS ~ $ /test_cpu

v=3

This is the single thing worked for me is to use gcc with it's __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); } } 

Admin@DESKTOP-4DBOBP9 MSYS ~ $ gcc /test_cpu.c -o /test_cpu

Admin@DESKTOP-4DBOBP9 MSYS ~ $ /test_cpu

v=3

Source Link
Loading