summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/kit/array_ref.h12
-rw-r--r--source/kit/string_ref.h2
-rw-r--r--source/test/unittests/array_ref.test.c4
3 files changed, 9 insertions, 9 deletions
diff --git a/source/kit/array_ref.h b/source/kit/array_ref.h
index f34927c..8ed065b 100644
--- a/source/kit/array_ref.h
+++ b/source/kit/array_ref.h
@@ -31,17 +31,17 @@ int kit_ar_compare(ptrdiff_t left_element_size, ptrdiff_t left_size,
type_ const *values; \
} name_
-#define KIT_AR_WRAP(name_, array_) \
+#define KIT_AR_WRAP(name_, element_type_, array_) \
struct { \
- ptrdiff_t size; \
- typeof((array_)[0]) *values; \
+ ptrdiff_t size; \
+ element_type_ *values; \
} name_ = { .size = (sizeof(array_) / sizeof((array_)[0])), \
.values = (array_) }
-#define KIT_AR_CONST_WRAP(name_, array_) \
+#define KIT_AR_CONST_WRAP(name_, element_type_, array_) \
struct { \
- ptrdiff_t size; \
- typeof((array_)[0]) const *values; \
+ ptrdiff_t size; \
+ element_type_ const *values; \
} name_ = { .size = (sizeof(array_) / sizeof((array_)[0])), \
.values = (array_) }
diff --git a/source/kit/string_ref.h b/source/kit/string_ref.h
index 8832e51..0e3468a 100644
--- a/source/kit/string_ref.h
+++ b/source/kit/string_ref.h
@@ -14,7 +14,7 @@ typedef kit_string_ref_t kit_out_str_t;
typedef kit_string_cref_t kit_cstr_t;
#define KIT_SZ(name_, static_str_) \
- KIT_AR_CONST(name_, typeof((static_str_)[0])) = { \
+ KIT_AR_CONST(name_, char) = { \
.size = (sizeof(static_str_) / sizeof((static_str_)[0])) - 1, \
.values = (static_str_) \
}
diff --git a/source/test/unittests/array_ref.test.c b/source/test/unittests/array_ref.test.c
index 27b754b..62556f3 100644
--- a/source/test/unittests/array_ref.test.c
+++ b/source/test/unittests/array_ref.test.c
@@ -5,7 +5,7 @@
TEST("array ref const wrap") {
int foo[] = { 1, 2, 3 };
- AR_CONST_WRAP(ref, foo);
+ AR_CONST_WRAP(ref, int, foo);
REQUIRE(ref.size == 3);
REQUIRE(ref.values[0] == 1);
@@ -15,7 +15,7 @@ TEST("array ref const wrap") {
TEST("array ref wrap") {
int foo[] = { 1, 2, 3 };
- AR_WRAP(ref, foo);
+ AR_WRAP(ref, int, foo);
REQUIRE(ref.size == 3);
REQUIRE(ref.values[0] == 1);