Define ADDRESS_SANITIZER portably using standard compiler macros
Use `__SANITIZE_ADDRESS__` (GCC) and `__has_feature(address_sanitizer)` (Clang) to define ADDRESS_SANITIZER when the toolchain doesn't provide it natively. Fixes #3160 PiperOrigin-RevId: 884447485 Change-Id: I48ef51bca8f5c5f15f62089e73cd8fa649723636
This commit is contained in:
committed by
Copybara-Service
parent
63bab26536
commit
eca5758bf9
@@ -58,6 +58,13 @@
|
||||
#define mjUNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
// Define ADDRESS_SANITIZER if implied by other macros.
|
||||
#if !defined(ADDRESS_SANITIZER)
|
||||
#if defined(__SANITIZE_ADDRESS__) || (defined(__has_feature) && __has_feature(address_sanitizer))
|
||||
#define ADDRESS_SANITIZER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user