title: Detect ARM NEON availability in the preprocessor?
body: <p>According to the <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/BABJFEFG.html" rel="noreferrer">ARM ARM</a>, <code>__ARM_NEON__</code> is defined when Neon SIMD instructions are available. I'm having trouble getting GCC to provide it.</p>
  
  <p>Neon available on this <a href="https://en.wikipedia.org/wiki/Banana_Pi#Banana_Pi_Pro" rel="noreferrer">BananaPi Pro</a> dev board running Debian 8.2:</p>
  
  <pre><code>$ cat /proc/cpuinfo | grep neon
  Features    : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
  </code></pre>
  
  <p>I'm using GCC 4.9:</p>
  
  <pre><code>$ gcc --version
  gcc (Debian 4.9.2-10) 4.9.2
  </code></pre>
  
  <p>Try GCC and <code>-march=native</code>:</p>
  
  <pre><code>$ g++ -march=native -dM -E - &lt;/dev/null | grep -i neon
  #define __ARM_NEON_FP 4
  </code></pre>
  
  <p>OK, try what Google uses for Android when building for Neon:</p>
  
  <pre><code>$ g++ -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -dM -E - &lt;/dev/null | grep -i neon
  #define __ARM_NEON_FP 4
  </code></pre>
  
  <p>Maybe a ARMv7-a with a hard float:</p>
  
  <pre><code>$ g++ -march=armv7-a -mfloat-abi=hard -dM -E - &lt;/dev/null | grep -i neon
  #define __ARM_NEON_FP 4
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li>why am I not seeing <code>__ARM_NEON__</code>?</li>
  <li>how do I detect Neon availability in the preprocessor?</li>
  </ul>
  
  <p>And maybe:</p>
  
  <ul>
  <li>what GCC switches should I use to enable Neon SIMD instructions?</li>
  </ul>
  
  <hr>
  
  <p>Related, on a <a href="http://www.lenovator.com/product/86.html" rel="noreferrer">LeMaker HiKey</a>, which is AARCH64/ARM64 running Linaro with GCC 4.9.2, here's the output from the preprocessor:</p>
  
  <pre><code>$ cpp -dM &lt;/dev/null | grep -i neon
  #define __ARM_NEON 1
  </code></pre>
  
  <p>According to ARM, this board does have Advanced SIMD instructions even though:</p>
  
  <pre><code>$ cat /proc/cpuinfo 
  Processor   : AArch64 Processor rev 3 (aarch64)
  ...
  Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32
  </code></pre>