summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/cbits_api.md2
-rw-r--r--include/stc/alt/cstr.h2
-rw-r--r--include/stc/cbits.h2
-rw-r--r--include/stc/ccommon.h2
-rw-r--r--include/stc/cstr.h2
-rw-r--r--include/stc/csview.h2
6 files changed, 6 insertions, 6 deletions
diff --git a/docs/cbits_api.md b/docs/cbits_api.md
index 1cf03c4c..b9cf5069 100644
--- a/docs/cbits_api.md
+++ b/docs/cbits_api.md
@@ -18,7 +18,7 @@ All cbits definitions and prototypes are available by including a single header
```c
cbits cbits_init(void);
-cbits cbits_new(c_strlit literal);
+cbits cbits_new(const char literal[]);
cbits cbits_from(const char* str);
cbits cbits_with_size(size_t size, bool value);
cbits cbits_with_values(size_t size, uint64_t pattern);
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h
index adad3e3d..82ebae91 100644
--- a/include/stc/alt/cstr.h
+++ b/include/stc/alt/cstr.h
@@ -82,7 +82,7 @@ STC_INLINE _cstr_rep_t cstr_rep_(cstr* self) {
/**************************** PUBLIC API **********************************/
-#define cstr_new(literal) cstr_from_n(literal, sizeof((c_strlit){literal}) - 1)
+#define cstr_new(literal) cstr_from_n(literal, c_strlen_lit(literal))
#define cstr_npos (SIZE_MAX >> 1)
#define cstr_null (c_make(cstr){.sso = {.cap_len = SSO_CAP}})
#define cstr_toraw(self) cstr_str(self)
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index 6c2235e7..af9336c1 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -78,7 +78,7 @@ STC_INLINE void cbits_drop(cbits* self) { c_free(self->data64); }
STC_INLINE size_t cbits_size(cbits set) { return set.size; }
#define cbits_new(literal) \
- cbits_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
+ cbits_from_n(literal, c_strlen_lit(literal))
STC_INLINE cbits* cbits_take(cbits* self, cbits other) {
if (self->data64 != other.data64) {cbits_drop(self); *self = other;}
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 263971a0..52daf837 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -77,7 +77,7 @@
# define c_free(p) free(p)
#endif
-typedef const char c_strlit[];
+#define c_strlen_lit(literal) (sizeof "" literal - 1U)
#define c_delete(T, ptr) do { T *_c_p = ptr; T##_drop(_c_p); c_free(_c_p); } while (0)
#define c_swap(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
#define c_arraylen(a) (sizeof (a)/sizeof (a)[0])
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index fc4c22d1..9ddf3d32 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -68,7 +68,7 @@ STC_INLINE cstr cstr_init() { return cstr_null; }
#define cstr_str(self) (self)->str
#define cstr_toraw(self) (self)->str
#define cstr_new(literal) \
- cstr_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
+ cstr_from_n(literal, c_strlen_lit(literal))
STC_INLINE cstr cstr_from(const char* str)
{ return cstr_from_n(str, strlen(str)); }
STC_INLINE char* cstr_data(cstr* self) { return self->str; }
diff --git a/include/stc/csview.h b/include/stc/csview.h
index c2bd041d..85ade552 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -38,7 +38,7 @@ STC_API csview csview_slice(csview sv, intptr_t p1, intptr_t p2);
STC_API csview csview_token(csview sv, csview sep, size_t* start);
#define csview_new(literal) \
- c_make(csview){literal, sizeof c_make(c_strlit){literal} - 1}
+ c_make(csview){literal, c_strlen_lit(literal)}
STC_INLINE csview csview_init() { return csview_null; }
STC_INLINE csview csview_from(const char* str)
{ return c_make(csview){str, strlen(str)}; }