From c0e7eaae8d6eef1e313c9d0da20ccf126ec61f38 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 5f3785b5..2f974036 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.