From af05a18b4c6438688d906d1f98922c36b32585cb Mon Sep 17 00:00:00 2001 From: Mike Beaton Date: Wed, 27 Nov 2024 00:01:17 +0000 Subject: [PATCH] MdePkg/BaseOverflowLib: Support BASE_ALIGNAS on VS2019 Note: this must be combined with flag /wd4324 added to MSFT:*_CC_FLAGS to avoid spurious warnings when the macro is working as intended. Update comment since alignment in all architectures can be used to align structure member or variable definition. --- MdePkg/Include/Library/BaseOverflowLib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Library/BaseOverflowLib.h b/MdePkg/Include/Library/BaseOverflowLib.h index 749b64d5b5..0714cdb917 100644 --- a/MdePkg/Include/Library/BaseOverflowLib.h +++ b/MdePkg/Include/Library/BaseOverflowLib.h @@ -32,9 +32,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define BASE_TYPE_ALIGNED(Type, Ptr) (BASE_POT_ALIGNED (BASE_ALIGNOF (Type), Ptr)) // -// Force member alignment for the structure. +// Force alignment for structure member or variable definition. // -#if (defined (__STDC__) && __STDC_VERSION__ >= 201112L) || defined (__GNUC__) || defined (__clang__) +#if defined (_MSC_VER) +#define BASE_ALIGNAS(Alignment) __declspec(align(Alignment)) +#elif (defined (__STDC__) && __STDC_VERSION__ >= 201112L) || defined (__GNUC__) || defined (__clang__) #define BASE_ALIGNAS(Alignment) _Alignas(Alignment) #else #define BASE_ALIGNAS(Alignment)