aboutsummaryrefslogtreecommitdiff
path: root/builtins/array.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-18 00:12:23 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-18 00:12:23 -0500
commit24a703199b06e483fd28823be64b87ec2ca44645 (patch)
tree4f510e7bbd5c1883ff5db9bd79f9504ec31abeaa /builtins/array.h
parentfbf39cd7e907f32824cc0bb763f38851b1726cfd (diff)
Compile tables
Diffstat (limited to 'builtins/array.h')
-rw-r--r--builtins/array.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtins/array.h b/builtins/array.h
index ae36795a..7c83e17d 100644
--- a/builtins/array.h
+++ b/builtins/array.h
@@ -10,7 +10,7 @@
// Convert negative indices to back-indexed without branching: index0 = index + (index < 0)*(len+1)) - 1
#define $index(x, i) _Generic(x, array_t: ({ __typeof(x) $obj; int64_t $offset = i; $offset += ($offset < 0) * ($obj.length + 1) - 1; assert($offset >= 0 && offset < $obj.length); $obj.data + $obj.stride * $offset;}))
#define $safe_index(x, i) _Generic(x, array_t: ({ __typeof(x) $obj; int64_t $offset = i - 1; $obj.data + $obj.stride * $offset;}))
-#define $array(x, ...) ({ __typeof(x) $items[] = {x, __VA_ARGS__}; \
+#define $Array(x, ...) ({ __typeof(x) $items[] = {x, __VA_ARGS__}; \
(array_t){.length=sizeof($items)/sizeof($items[0]), \
.stride=(int64_t)&$items[1] - (int64_t)&$items[0], \
.data=memcpy(GC_MALLOC(sizeof($items)), $items, sizeof($items)), \