From: Alejandro Colomar <alx@kernel.org>
To: Mark Harris <mark.hsj@gmail.com>
Cc: Paul Eggert <eggert@cs.ucla.edu>, linux-man@vger.kernel.org
Subject: Re: QChar and QVoid for strchr(3), memchr(3), et al.
Date: Wed, 25 Feb 2026 02:15:38 +0100 [thread overview]
Message-ID: <aZ5KlMue5WUSlRgh@devuan> (raw)
In-Reply-To: <CAMdZqKF8wO5Kq8ac4t7r9_8GkYSe=XN70SAa5e699zkSncMcqQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]
Hi Mark,
On 2026-02-24T17:03:02-0800, Mark Harris wrote:
> > strchr(3)
> > SYNOPSIS
> > #include <string.h>
> >
> > QChar *strchr(QChar *s, int c);
> >
> > #undef strchr
> > char *strchr(const char *s, int c);
>
> I don't see how anyone would understand what this is trying to convey,
> unless they were already familiar with the C23 changes to strchr. The
> #undef in the middle makes it worse, because it appears to be going
> out of its way to describe the function using strict C syntax, even to
> the point of sacrificing normal synopsis conventions and clarity.
While it would be new to use #undef in SYNOPSIS, we already have #define
in many places (as a way to document necessary feature test macros).
Here's an example, which uses it in the middle of the section (more
often, it goes before the first #include):
SYNOPSIS
#include <string.h>
char *strstr(const char *haystack, const char *needle);
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
char *strcasestr(const char *haystack, const char *needle);
Using #undef wouldn't be too extraneous compared to this, I think.
> However QChar is not a C type or macro, so by making it appear that
> the synopsis is supposed to be interpreted strictly as C code it just
> ends up making it more confusing. The C23 style only works if you can
> put QChar in italics, as in C23, or some other style that clearly
> distinguishes it from a type name or C code.
Yup, I'd use some style that makes it distinct from regular types.
Maybe italics, or maybe roman. That's the least of our problems.
> If you don't like the
> two-line synopsis it would be better to just leave the synopsis as it
> was, and add a sentence to the description that in C23 a
> const-qualified argument propagates the const qualification to the
> result type.
I prefer the overload syntax over the old syntax, because the old syntax
is confusing people. This week someone was surprised because the
SYNOPSIS clearly shows the old syntax, but their test on Arch with the
latest glibc rejected some code that was correct according to the shown
prototype. So we need to clearly document that the prototype is now
different, somehow.
Thanks for the feedback!
Have a lovely night!
Alex
>
> - Mark
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-02-25 1:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 14:28 QChar and QVoid for strchr(3), memchr(3), et al Alejandro Colomar
2026-02-24 16:56 ` Mark Harris
2026-02-24 17:14 ` Paul Eggert
2026-02-24 21:31 ` Alejandro Colomar
2026-02-24 23:04 ` Paul Eggert
2026-02-24 23:05 ` Alejandro Colomar
2026-02-24 23:19 ` Paul Eggert
2026-02-24 23:34 ` Alejandro Colomar
2026-02-25 1:03 ` Mark Harris
2026-02-25 1:15 ` Alejandro Colomar [this message]
2026-02-24 18:52 ` Rene Kita
2026-02-24 21:41 ` Alejandro Colomar
2026-02-25 15:48 ` Rene Kita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZ5KlMue5WUSlRgh@devuan \
--to=alx@kernel.org \
--cc=eggert@cs.ucla.edu \
--cc=linux-man@vger.kernel.org \
--cc=mark.hsj@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox