sv/include/sv.h

24 lines
412 B
C
Raw Normal View History

2025-07-10 23:51:28 +00:00
#ifndef SV_INCLUDED
#define SV_INCLUDED
#include <stddef.h>
// macros
#define SV(s) sv_str(s)
#define SV_NULL sv_strn(NULL, 0)
// printf macros
#define SV_FMT "%.*s"
#define SV_ARG(sv) (int) (sv).len, (sv).buf
struct String_View{
size_t len; // String lenght
const char *buf; // String data
};
typedef struct String_View SV;
SV sv_str(const char *s);
SV sv_strn(const char *s, size_t len);
#endif