Add placeholder for stringifying arrays of unknown type

This commit is contained in:
Bruce Hill 2024-02-12 01:36:46 -05:00
parent 2c5401aaf7
commit 179648b005
2 changed files with 2 additions and 0 deletions

View File

@ -85,6 +85,7 @@ static CORD vas_cord(void *x, const char **fmt, va_list args)
void *arg = va_arg(args, void*);
return fn(x, arg);
}
case ' ': return "?";
default: errx(1, "Unsupported format specifier: '%c'", c);
}
errx(1, "Unreachable");

View File

@ -39,6 +39,7 @@ CORD as_cord(void *x, const char *fmt, ...);
double: CORD_asprintf("%g", x), float: CORD_asprintf("%g", x), \
CORD: x, \
char*: (CORD)({ const char *__str = x; __str && __str[0] ? __str : CORD_EMPTY;}), \
array_t: as_cord(&(x), "[ ]"), \
default: "???")
#define __heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x))
#define __stack(x) &(x)