From 45cf4710c476d30ff31333590b3ec85339033016 Mon Sep 17 00:00:00 2001 From: Valeri Date: Fri, 1 Dec 2023 04:19:47 +0300 Subject: [PATCH] Use the appropriate version of alignof --- include/cglm/types.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/cglm/types.h b/include/cglm/types.h index bafebe6..65391cd 100644 --- a/include/cglm/types.h +++ b/include/cglm/types.h @@ -8,6 +8,10 @@ #ifndef cglm_types_h #define cglm_types_h +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +# include +#endif + #if defined(_MSC_VER) /* do not use alignment for older visual studio versions */ # if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */ @@ -57,8 +61,16 @@ # define CGLM_ASSUME_ALIGNED(expr, alignment) (expr) #endif -#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ - ((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type))) +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ + ((type*)CGLM_ASSUME_ALIGNED((expr), alignof(type))) +#elif defined(_MSC_VER) +# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ + ((type*)CGLM_ASSUME_ALIGNED((expr), __alignof(type))) +#else +# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ + ((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type))) +#endif typedef int ivec2[2]; typedef int ivec3[3];