From f4c9ddf5307eb7b485e91398994ecc80c88f999a Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Tue, 7 Mar 2023 10:17:44 +1100 Subject: [PATCH] Check for builtin before using it The check for __has_builtin being defined and using the __has_builtin() macro need to be on different lines, as when __has_builtin is not defined, using the __has_builtin() macro is an invalid preprocessor directive. --- include/cglm/types.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/cglm/types.h b/include/cglm/types.h index a671c5a9f..e6011c352 100644 --- a/include/cglm/types.h +++ b/include/cglm/types.h @@ -32,9 +32,13 @@ # define CGLM_ALIGN_MAT CGLM_ALIGN(16) #endif -#ifdef __GNUC__ -# define CGLM_ASSUME_ALIGNED(expr, alignment) \ - __builtin_assume_aligned((expr), (alignment)) +#if defined(__has_builtin) +# if __has_builtin(__builtin_assume_aligned) +# define CGLM_ASSUME_ALIGNED(expr, alignment) \ + __builtin_assume_aligned((expr), (alignment)) +# else +# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr) +# endif #else # define CGLM_ASSUME_ALIGNED(expr, alignment) (expr) #endif