I work on a program written in C, which I sometimes create with a sanitizer for the address, mainly for detecting errors. The program prints a banner in the magazines when it runs information such as: who created it, the branch on which it was built, the compiler, etc. I thought it would be nice to also indicate if the binary was created using sanitizer for the address. I know __has_feature (address_sanitizer) there, but this only works for clang. I tried the following simple program:
#include <stdio.h> 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; }
When building with gcc -Wall -g -fsanitize=address -o asan asan.c this gives:
We got nothing!
With clang -Wall -g -fsanitize=address -o asan asan.c I get:
We has ASAN!
Is there gcc equivalent of __has_feature?
I know that there are ways to check, for example, the huge value of VSZ for programs created with a sanitizer for the address, just wondering if there is a definition of compilation time or something like that.
c gcc clang address-sanitizer
fencekicker
source share