#if __cplusplus >= 201703L && !defined(__STRICT_ANSI__) // C++17 or later code here #else // C++11 or earlier code here #endif
#ifdef __x86_64__ __builtin_cpu_init(); if (__builtin_cpu_supports("avx2")) { // AVX2 code here } else if (__builtin_cpu_supports("avx")) { // AVX code here } #endifThis code uses the __builtin_cpu_supports intrinsic to detect if the current CPU architecture supports AVX or AVX2 instructions, and then selects the corresponding code path. getLangOpts is used to detect if the current architecture is x86_64. The getLangOpts preprocessor directive is part of the standard C and C++ libraries and is usually provided by the compiler.