How does code know that it is compiled or running with AddressSanitizer or ThreadSanitizer?

  address-sanitizer, c++, thread-sanitizer

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.

Source: Windows Questions C++

LEAVE A COMMENT