apple clang -fopenmp not working

There is a way to use OpenMP with just Apple Clang. I learnt it while hacking a formula in Homebrew. You need libomp from Homebrew (brew install libomp), and then a different command-line option.

If you originally want to use clang -fopenmp test.c, with Apple Clang you need to use this alternative command:

clang -Xpreprocessor -fopenmp test.c -lomp

From what I learned so far is that clang that comes with xcode does not support openmp. Also, the versions are different. So clang that comes with xcode 8 has version 8...

The best solution I have found so far is to install clang using homebrew: brew install llvm --with-clang. Right now I got version 3.9.0 and it does support openmp, so it solves my problem.