From 9214a8e44d805087dd6ba86bacc1e7970d3bf0f2 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 30 Dec 2025 16:17:55 +0100 Subject: [PATCH] lib/: Use non-empty compound literals While the empty one is more correct, {0} will also work, and will likely silence diagnostics in old compiler versions. Empty compound literals are only supported in GCC since commit gcc.git 14cfa01755a6 (2022-08-25; "c: Support C2x empty initializer braces") Reported-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- lib/atoi/a2i.h | 2 +- lib/search/cmp/cmp.h | 2 +- lib/sizeof.h | 2 +- lib/typetraits.h | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/atoi/a2i.h b/lib/atoi/a2i.h index 6d67496f..e7ece423 100644 --- a/lib/atoi/a2i.h +++ b/lib/atoi/a2i.h @@ -26,7 +26,7 @@ \ int status; \ \ - *n_ = _Generic((T){}, \ + *n_ = _Generic((T){0}, \ short: strtoi_, \ int: strtoi_, \ long: strtoi_, \ diff --git a/lib/search/cmp/cmp.h b/lib/search/cmp/cmp.h index 3e81e052..d9ed1ab0 100644 --- a/lib/search/cmp/cmp.h +++ b/lib/search/cmp/cmp.h @@ -11,7 +11,7 @@ #define CMP(T) \ ( \ - _Generic((T){}, \ + _Generic((T){0}, \ int: cmp_int, \ long: cmp_long, \ unsigned int: cmp_uint, \ diff --git a/lib/sizeof.h b/lib/sizeof.h index 0b82ac97..1fc38873 100644 --- a/lib/sizeof.h +++ b/lib/sizeof.h @@ -15,7 +15,7 @@ #include -#define typeas(T) typeof((T){}) +#define typeas(T) typeof((T){0}) #define ssizeof(x) ({(ssize_t){sizeof(x)};}) #define memberof(T, member) ((T){}.member) diff --git a/lib/typetraits.h b/lib/typetraits.h index 051edfc6..fb3d970d 100644 --- a/lib/typetraits.h +++ b/lib/typetraits.h @@ -57,10 +57,10 @@ #define QChar_of(s) typeof \ ( \ _Generic(s, \ - const char *: (const char){}, \ - const void *: (const char){}, \ - char *: (char){}, \ - void *: (char){} \ + const char *: (const char){0}, \ + const void *: (const char){0}, \ + char *: (char){0}, \ + void *: (char){0} \ ) \ )