From d44aeb28ed2eefa8a3b41d7db23b2f9b3ee4744a Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Sat, 1 Jun 2024 14:44:04 +0300 Subject: [PATCH] sysdefs.h: Add alignas --- src/common/sysdefs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/sysdefs.h b/src/common/sysdefs.h index 5f3785b51..2f9740367 100644 --- a/src/common/sysdefs.h +++ b/src/common/sysdefs.h @@ -156,6 +156,17 @@ typedef unsigned char _Bool; # define __bool_true_false_are_defined 1 #endif +// We may need alignas from C11/C17/C23. +#if __STDC_VERSION__ >= 202311 + // alignas is a keyword in C23. Do nothing. +#elif __STDC_VERSION__ >= 201112 +# include +#elif defined(__GNUC__) || defined(__clang__) +# define alignas(n) __attribute__((__aligned__(n))) +#else +# define alignas(n) +#endif + #include // Visual Studio 2013 update 2 supports only __inline, not inline.