]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/typetraits.h: QChar_of(): Add macro
authorAlejandro Colomar <alx@kernel.org>
Sun, 19 Oct 2025 08:10:37 +0000 (10:10 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 02:23:43 +0000 (20:23 -0600)
This macro is useful to implement QChar versions of functions.
See ISO C23 for a description of what QChar is.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/typetraits.h

index ce29a8f323f0d522b9e635a4ff7876782f0c3adb..051edfc66f14d83cc9573a1ddb32ab26ffb3a1ed 100644 (file)
 )
 
 
+#define QChar_of(s)  typeof                                           \
+(                                                                     \
+       _Generic(s,                                                   \
+               const char *:  (const char){},                        \
+               const void *:  (const char){},                        \
+               char *:        (char){},                              \
+               void *:        (char){}                               \
+       )                                                             \
+)
+
+
 #endif  // include guard