sv: SV_AUTO macro (for literal strings/literal byte arrays really).

This commit is contained in:
2026-02-10 16:33:11 +00:00
committed by oreodave
parent daa1d3d565
commit 818d4da850
3 changed files with 9 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ typedef struct
// String view macro constructor
#define SV(DATA, SIZE) ((sv_t){.data = (DATA), .size = (SIZE)})
#define SV_AUTO(DATA) ((sv_t){.data = (void *)(DATA), .size = sizeof(DATA) - 1})
// Pretty printers
#define SV_FMT(SV) (int)(SV).size, (SV).data
#define PR_SV "%.*s"