I would like for my C++ program to be able to print if it was compiled with AddressSanitizer or ThreadSanitizer. The solution proposed in AddressSanitizer: How could we know that object file/executable in C is compiled with AddressSanitizer? will not work because I do not want the program to have to open its own object code and explore itself that way. Is there a #define
that it can check for? I can add my own, but I don't want to add one if one already exists.
Asked
Active
Viewed 35 times
0

vy32
- 28,461
- 37
- 122
- 246
-
1When you compile with AddressSanitizer you can also define `-DASAN=1`, or ThreadSanitizer `-DTSAN=1`. I see that `-fsanitize=address` already supplied pre-define `_FORTIFY_SOURCE` but I don't know if that's long term reliable. I don't see ThreadSanitizer having a pre-define. – Eljay Jan 11 '22 at 13:02
-
It does. I will delete this. Thanks. I wonder why search did not turn that up. – vy32 Jan 12 '22 at 14:33