Clang, detecting -mavx compiler argument on the source code side

avx, c++, clang

Solution

The right test is on `__AVX__`, it works just as well with clang as with gcc. It even works with Visual Studio...

Problem

When I use GCC and set the command line argument -mavx, then the compiler will automagically define `__AVX__` in the source code. This way I can detect if the project is built with AVX instructions and if not fall back to another code path. Is there a way to do the same thing with Clang? Thanks, Christophe

Original source