summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/stc/ccommon.h6
-rw-r--r--include/stc/cspan.h2
-rw-r--r--misc/examples/printspan.c17
3 files changed, 14 insertions, 11 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 35bc9335..286450ec 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -112,10 +112,10 @@
#define c_no_hash (1<<6)
#define c_no_lookup (c_no_cmp|c_no_eq|c_no_hash)
-#define c_init(C, ...) \
- C##_from_n((C##_raw[])__VA_ARGS__, sizeof((C##_raw[])__VA_ARGS__)/sizeof(C##_raw))
+/* Function macros and others */
-/* Function macros and various others */
+#define c_make(C, ...) \
+ C##_from_n((C##_raw[])__VA_ARGS__, sizeof((C##_raw[])__VA_ARGS__)/sizeof(C##_raw))
typedef const char* crawstr;
#define crawstr_cmp(xp, yp) strcmp(*(xp), *(yp))
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index 1e12781e..502f1b71 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -90,7 +90,7 @@ int demo2() {
#define cspan_make(array, ...) \
{.data=array, .dim={__VA_ARGS__}}
-/* For static initialization use , cspan_init(). c_init() only works for non-static. */
+/* For static initialization use , cspan_init(). c_make() only works for non-static. */
#define cspan_init(SpanType, ...) \
{.data=(SpanType##_value[])__VA_ARGS__, .dim={sizeof((SpanType##_value[])__VA_ARGS__)/sizeof(SpanType##_value)}}
diff --git a/misc/examples/printspan.c b/misc/examples/printspan.c
index 8d0b0321..227fd2ed 100644
--- a/misc/examples/printspan.c
+++ b/misc/examples/printspan.c
@@ -27,25 +27,28 @@ int main()
c_AUTO (cdeq_int, deq)
c_AUTO (cset_str, set)
{
- printMe( c_init(intspan, {1, 2, 3}) );
+ intspan sp1 = cspan_init(intspan, {1, 2});
+ printMe( sp1 );
+
+ printMe( c_make(intspan, {1, 2, 3}) );
int arr[] = {1, 2, 3, 4, 5, 6};
- intspan span = cspan_from_array(arr);
- printMe( (intspan)cspan_subspan(&span, 1, 4) );
+ intspan sp2 = cspan_from_array(arr);
+ printMe( (intspan)cspan_subspan(&sp2, 1, 4) );
c_FORLIST (i, int, {1, 2, 3, 4, 5})
cvec_int_push(&vec, *i.ref);
printMe( (intspan)cspan_from(&vec) );
- printMe( span );
+ printMe( sp2 );
- stk = c_init(cstack_int, {1, 2, 3, 4, 5, 6, 7});
+ stk = c_make(cstack_int, {1, 2, 3, 4, 5, 6, 7});
printMe( (intspan)cspan_from(&stk) );
- deq = c_init(cdeq_int, {1, 2, 3, 4, 5, 6, 7, 8});
+ deq = c_make(cdeq_int, {1, 2, 3, 4, 5, 6, 7, 8});
printMe( (intspan)cspan_from(&deq) );
- set = c_init(cset_str, {"1", "2", "3", "4", "5", "6", "7", "8", "9"});
+ set = c_make(cset_str, {"1", "2", "3", "4", "5", "6", "7", "8", "9"});
printf("%d:", (int)cset_str_size(&set));
c_FOREACH (e, cset_str, set)
printf(" %s", cstr_str(e.ref));