From a000912f39108dfe5fc1ce91fbe47905c797b396 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 14 Apr 2025 16:10:26 -0600 Subject: [PATCH] AK: Add macro to switch between no_unique_address attribute forms Also add an escape hatch for completely disabling the annotation. --- AK/Platform.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/AK/Platform.h b/AK/Platform.h index ad719cbf160..cc72d7d5058 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -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