Skip to content

Commit e8035f1

Browse files
authored
ggml : fix static_assert with older compilers ggml-org#2024 (ggml-org#2218)
1 parent 7513b7b commit e8035f1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ggml.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@
3131
#include <unistd.h>
3232
#endif
3333

34+
// static_assert should be a #define, but if it's not,
35+
// fall back to the _Static_assert C11 keyword.
3436
// if C99 - static_assert is noop
3537
// ref: https://stackoverflow.com/a/53923785/4039976
3638
#ifndef static_assert
39+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
40+
#define static_assert(cond, msg) _Static_assert(cond, msg)
41+
#else
3742
#define static_assert(cond, msg) struct global_scope_noop_trick
3843
#endif
44+
#endif
3945

4046
#if defined(_MSC_VER)
4147
// disable "possible loss of data" to avoid hundreds of casts
@@ -112,10 +118,6 @@ typedef void * thread_ret_t;
112118
#endif
113119
#endif
114120

115-
#ifdef __HAIKU__
116-
#define static_assert(cond, msg) _Static_assert(cond, msg)
117-
#endif
118-
119121
/*#define GGML_PERF*/
120122
#define GGML_DEBUG 0
121123
#define GGML_GELU_FP16

k_quants.h

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#define K_SCALE_SIZE 12
1616
#endif
1717

18+
#ifndef static_assert
19+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
20+
#define static_assert(cond, msg) _Static_assert(cond, msg)
21+
#else
22+
#define static_assert(cond, msg) struct global_scope_noop_trick
23+
#endif
24+
#endif
25+
1826
//
1927
// Super-block quantization structures
2028
//

0 commit comments

Comments
 (0)