Wed, 08 Oct 2025 20:09:32 +0200
add unsigned char strings to cx_strcast() and changes documentation
also relates to #700
src/cx/string.h | file | annotate | diff | comparison | revisions |
--- a/src/cx/string.h Fri Oct 03 18:58:44 2025 +0200 +++ b/src/cx/string.h Wed Oct 08 20:09:32 2025 +0200 @@ -304,20 +304,16 @@ } /** -* Casts a mutable string to an immutable string. -* -* Does nothing for already immutable strings. -* -* @note This is not seriously a cast. Instead, you get a copy -* of the struct with the desired pointer type. Both structs still -* point to the same location, though! -* -* @param str (@c cxstring or @c cxmutstr) the string to cast -* @return (@c cxstring) an immutable copy of the string pointer -*/ + * Wraps any string into an UCX string. + * + * @param str (any supported string type) the string to cast + * @return (@c cxstring) the string wrapped as UCX string + */ #define cx_strcast(str) _Generic((str), \ cxmutstr: cx_strcast_m, \ cxstring: cx_strcast_c, \ + const unsigned char*: cx_strcast_z, \ + unsigned char *: cx_strcast_z, \ const char*: cx_strcast_z, \ char *: cx_strcast_z) (str) #endif