mirror of https://github.com/acidanthera/audk.git
MdePkg/Base.h: Add support for C++ alignof
In preparation of including Base.h in C++ BaseTools programs, support the C++ 11 alignof operator. The C _Alignof operator is not universally supported in C++ mode across compiler toolchains and thus the current definition may lead to compilation errors with said programs. Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
This commit is contained in:
parent
2531248905
commit
029d44255f
|
@ -765,23 +765,30 @@ typedef UINTN *BASE_LIST;
|
|||
|
||||
@return Alignment requirement, in Bytes, of TYPE.
|
||||
**/
|
||||
#if defined (__cplusplus)
|
||||
//
|
||||
// Standard C++ operator.
|
||||
//
|
||||
#define ALIGNOF(TYPE) alignof (TYPE)
|
||||
#elif defined (__GNUC__) || defined (__clang__) || (defined (_MSC_VER) && _MSC_VER >= 1900)
|
||||
//
|
||||
// All supported versions of GCC and Clang, as well as MSVC 2015 and later,
|
||||
// support the standard operator _Alignof.
|
||||
//
|
||||
#define ALIGNOF(TYPE) _Alignof (TYPE)
|
||||
#elif defined (_MSC_EXTENSIONS)
|
||||
//
|
||||
// Earlier versions of MSVC, at least MSVC 2008 and later, support the vendor
|
||||
// extension __alignof.
|
||||
//
|
||||
#define ALIGNOF(TYPE) __alignof (TYPE)
|
||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||
//
|
||||
// C++ 11 and later support the standard operator alignof.
|
||||
//
|
||||
#define ALIGNOF(TYPE) alignof (TYPE)
|
||||
#elif ((defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1900)) && !defined (__cplusplus)) || defined(__clang__)
|
||||
//
|
||||
// All supported versions of GCC and Clang, as well as MSVC 2015 and later,
|
||||
// support the standard operator _Alignof in C mode. GCC and MSVC do not
|
||||
// support it in C++ mode though.
|
||||
//
|
||||
#define ALIGNOF(TYPE) _Alignof (TYPE)
|
||||
#elif defined(__GNUC__)
|
||||
//
|
||||
// GCC does not support _Alignof in C++ mode, unlike Clang. The vendor-
|
||||
// extenstion is supported in both C and C++ mode.
|
||||
//
|
||||
#define ALIGNOF(TYPE) __alignof__ (TYPE)
|
||||
#elif defined(_MSC_EXTENSIONS)
|
||||
//
|
||||
// Earlier versions of MSVC, at least MSVC 2008 and later, as well as current
|
||||
// versions in C++ mode support the vendor-extension __alignof.
|
||||
//
|
||||
#define ALIGNOF(TYPE) __alignof (TYPE)
|
||||
#else
|
||||
//
|
||||
// For compilers that do not support inbuilt alignof operators, use OFFSET_OF.
|
||||
|
|
Loading…
Reference in New Issue