aboutsummaryrefslogtreecommitdiff
path: root/ggml.c
diff options
context:
space:
mode:
authorEvan Miller <emmiller@gmail.com>2023-07-14 14:55:56 -0400
committerGitHub <noreply@github.com>2023-07-14 21:55:56 +0300
commite8035f141e1f71d739fa5cfc9c01531cdee6fc16 (patch)
tree91c4a0527fb4fb5ad7f03457675c1b2e5c59af73 /ggml.c
parent7513b7b0a1c11faa00ad5a34d22681e5f07d32e4 (diff)
ggml : fix static_assert with older compilers #2024 (#2218)
Diffstat (limited to 'ggml.c')
-rw-r--r--ggml.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ggml.c b/ggml.c
index f5821f1..3ea8ba6 100644
--- a/ggml.c
+++ b/ggml.c
@@ -31,11 +31,17 @@
#include <unistd.h>
#endif
+// static_assert should be a #define, but if it's not,
+// fall back to the _Static_assert C11 keyword.
// if C99 - static_assert is noop
// ref: https://stackoverflow.com/a/53923785/4039976
#ifndef static_assert
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
+#define static_assert(cond, msg) _Static_assert(cond, msg)
+#else
#define static_assert(cond, msg) struct global_scope_noop_trick
#endif
+#endif
#if defined(_MSC_VER)
// disable "possible loss of data" to avoid hundreds of casts
@@ -112,10 +118,6 @@ typedef void * thread_ret_t;
#endif
#endif
-#ifdef __HAIKU__
-#define static_assert(cond, msg) _Static_assert(cond, msg)
-#endif
-
/*#define GGML_PERF*/
#define GGML_DEBUG 0
#define GGML_GELU_FP16