added str_expand

This commit is contained in:
Timerix 2025-11-27 01:23:41 +05:00
parent 83091ac707
commit f3e4f8f061

View File

@ -13,7 +13,13 @@ typedef struct str {
bool isZeroTerminated; bool isZeroTerminated;
} str; } str;
/*
USAGE:
str s = STR("something");
printf(FMT_str"\n", str_expand(s));
*/
#define FMT_str "%.*s" #define FMT_str "%.*s"
#define str_expand(s) s.len, s.data
/// creates str from a string literal /// creates str from a string literal
#define STR(LITERAL) str_construct(LITERAL, ARRAY_LEN(LITERAL) - 1, true) #define STR(LITERAL) str_construct(LITERAL, ARRAY_LEN(LITERAL) - 1, true)