How to detect if building with address sanitizer when building with gcc 4.8? : <p>I'm working on a program written in C that I occasionally build with address sanitizer, basically to catch bugs. The program prints a banner in the logs when it starts up with info such as: who built it, the branch it was built on, compiler etc. I was thinking it would be nice to also spell out if the binary was built using address sanitizer. I know there's __has_feature(address_sanitizer), but that only works for clang. I tried the following simple program: </p>

<pre><code>#include &lt;stdio.h&gt;

int main()
{
#if defined(__has_feature)
# if __has_feature(address_sanitizer)
    printf ("We has ASAN!\n");
# else
    printf ("We have has_feature, no ASAN!\n");
# endif
#else
    printf ("We got nothing!\n");
#endif

    return 0;
}
</code></pre>

<p>When building with <code>gcc -Wall -g -fsanitize=address -o asan asan.c</code>, this yields: </p>

<pre><code>We got nothing!
</code></pre>

<p>With <code>clang -Wall -g -fsanitize=address -o asan asan.c</code> I get: </p>

<pre><code>We has ASAN!
</code></pre>

<p>Is there a gcc equivalent to __has_feature? </p>

<p>I know there are ways to check, like the huge VSZ value for programs built with address sanitizer, just wondering if there's a compile-time define or something. </p>
