Baselib_Alignment.h 848 B

123456789101112131415161718192021
  1. #pragma once
  2. #ifndef BASELIB_ALIGN_OF
  3. #if defined(__cplusplus) // We assume C++11 support (also, note that Mscv has correct version numbers on this attribute as opt-in)
  4. #define BASELIB_ALIGN_OF(TYPE_) alignof(TYPE_)
  5. // As of gcc8+clang 8, alignof and _Alignof return the ABI alignment of a type, as opposed to the preferred alignment.
  6. // __alignof still returns the preferred alignment.
  7. // Also see:
  8. // https://gcc.gnu.org/gcc-8/porting_to.html#alignof
  9. // https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#modified-compiler-flags
  10. #elif STDC_VERSION >= 201112L
  11. #define BASELIB_ALIGN_OF(TYPE_) _Alignof(TYPE_)
  12. #else
  13. #define BASELIB_ALIGN_OF(TYPE_) COMPILER_ALIGN_OF(TYPE_)
  14. #endif
  15. #endif
  16. #ifndef BASELIB_ALIGN_AS
  17. #define BASELIB_ALIGN_AS(ALIGNMENT_) COMPILER_ALIGN_AS(ALIGNMENT_)
  18. #endif