diff options
| author | Tyge Løvset <[email protected]> | 2023-01-22 16:22:51 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-22 16:22:51 +0100 |
| commit | af74e5f44af8f03ec3b0b2ffd3fd577210707e49 (patch) | |
| tree | 5905f4c80190161cdc9f814e78a7a87030cae1c7 /include | |
| parent | 01bffb4d3b6b175db264c5cc30b1b7e756560639 (diff) | |
| download | STC-modified-af74e5f44af8f03ec3b0b2ffd3fd577210707e49.tar.gz STC-modified-af74e5f44af8f03ec3b0b2ffd3fd577210707e49.zip | |
Added cspan_init() for static initializing and a minor fix. Added cregex replace tests.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cspan.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/stc/cspan.h b/include/stc/cspan.h index 96439c64..1e12781e 100644 --- a/include/stc/cspan.h +++ b/include/stc/cspan.h @@ -61,7 +61,7 @@ int demo2() { #include "ccommon.h" #define using_cspan(Self, T, RANK) \ - typedef T Self##_value, Self##_raw; \ + typedef T Self##_value; typedef T Self##_raw; \ typedef struct { Self##_value *ref, *end; } Self##_iter; \ typedef struct { Self##_value *data; uint32_t dim[RANK]; } Self; \ \ @@ -90,6 +90,10 @@ int demo2() { #define cspan_make(array, ...) \ {.data=array, .dim={__VA_ARGS__}} +/* For static initialization use , cspan_init(). c_init() only works for non-static. */ +#define cspan_init(SpanType, ...) \ + {.data=(SpanType##_value[])__VA_ARGS__, .dim={sizeof((SpanType##_value[])__VA_ARGS__)/sizeof(SpanType##_value)}} + /* create a cspan from a cvec, cstack, cdeq, cqueue, or cpque (heap) */ #define cspan_from(container) \ {.data=(container)->data, .dim={(uint32_t)(container)->_len}} |
