AK: Add macro to switch between no_unique_address attribute forms

Also add an escape hatch for completely disabling the annotation.
This commit is contained in:
Andrew Kaster 2025-04-14 16:10:26 -06:00
parent 2a15b85658
commit a000912f39

View file

@ -247,6 +247,19 @@
# define DISALLOW(message) __attribute__((error(message)))
#endif
#ifdef NO_UNIQUE_ADDRESS
# undef NO_UNIQUE_ADDRESS
#endif
#if defined(AK_DISABLE_NO_UNIQUE_ADDRESS)
# define NO_UNIQUE_ADDRESS
#else
# if defined(AK_OS_WINDOWS)
# define NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
# else
# define NO_UNIQUE_ADDRESS [[no_unique_address]]
# endif
#endif
// GCC doesn't have __has_feature but clang does
#ifndef __has_feature
# define __has_feature(...) 0