|
|
Message-ID: <xf42owwkx2yuqf4cxg65zac4b2qcgvv4dlajrbic4kbpzwwphy@nxmm3wsijtkm>
Date: Sat, 29 Nov 2025 18:31:15 +0100
From: Alejandro Colomar <alx@...nel.org>
To: Luca Kellermann <mailto.luca.kellermann@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v4 1/1] include/string.h: Implement QChar and
QVoid wrappers standardized in C23
Hi Luca,
On Sat, Nov 29, 2025 at 02:53:15PM +0100, Luca Kellermann wrote:
> On Thu, 27 Nov 2025 17:27:27 +0100 Alejandro Colomar wrote:
> > Co-authored-by: Markus Wichmann <nullplan@....net>
> > Signed-off-by: Alejandro Colomar <alx@...nel.org>
> > ---
> > include/string.h | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/include/string.h b/include/string.h
> > index 83e2b946..454d93a7 100644
> > --- a/include/string.h
> > +++ b/include/string.h
> > @@ -24,6 +24,15 @@ extern "C" {
> >
> > #include <bits/alltypes.h>
> >
> > +#define __QVoidptrof(p) typeof(1?(p):(void*)"")
>
> Another expression to use instead of (void*)"" would be (void*){}. If
> I'm not mistaken, this expression is not a null pointer constant, even
> if its value is a null pointer. This would help avoid warnings with
> -Wwrite-strings and -Wcast-qual.
Ahh, good idea. That'll be better.
> > +#define __QCharptrof(s) typeof \
> > +( \
> > + _Generic(__QVoidptrof(s), \
> > + const void *: (const char *) 0, \
> > + void *: (char *) 0 \
> > + ) \
> > +)
>
> I think the controlling expression of a generic selection must be an
> expression. __QVoidptrof(s) is a type. A compound literal could be
> used instead:
>
> _Generic((__QVoidptrof(s)){}, ...)
Ahh, yeah, types are allowed in ISO C2y and recent-enough compilers, but
expressions are more portable.
BTW, for the curious, expressions undergo lvalue conversion, but types
don't, so an expression (const int){} as a generic controlling
expression matches type int, but the type 'const int' would match type
'const int'.
So, yes, I'll apply both suggestions.
Have a lovely night!
Alex
>
> > [...]
>
> Luca
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.