[RFC v1 1/1] string: Add streq(), memeq(), wcseq(), wmemeq()

Alejandro Colomar alx@kernel.org
Mon Sep 1 15:55:17 GMT 2025


Hi Adhemerval,

On Mon, Sep 01, 2025 at 12:18:51PM -0300, Adhemerval Zanella Netto wrote:
> >> I am aware this is a RFC, but this patch triggered some CI issues [1], where
> >> some old standard modes do not support '_Bool'.
> > 
> > Yup, I found some issues while running 'make check', although not in
> > 'make'.  About the issues with _Bool, they seem to come from C++, not
> > old versions of C.  AFAIK, _Bool is supported in GCC in every language
> > version (except in pedantic C89 maybe?).
> 
> It is for C89 [1]:
> 
> :::: -std=c89 -D_GNU_SOURCE=1
> In file included from ../include/string.h:60,
>                  from ../inet/netinet/icmp6.h:22,
>                  from ../include/netinet/icmp6.h:1,
>                  from /tmp/cih_test_4ZNjF5.c:10:
> ../string/string.h:86:14: error: expected ';' before '_Bool'
>    86 | static inline _Bool
>       |              ^~~~~~
>       |              ;
> ../string/string.h:172:14: error: expected ';' before '_Bool'
>   172 | static inline _Bool
>       |              ^~~~~~
>       |              ;

Hmmm.

> [1] https://www.delorie.com/trybots/32bit/51367/inet-check-installed-headers-c.out
> 
> > 
> > How would you proceed about bool?  I could add a macro, which would
> > evaluate to an int instead of a bool, and would sovle this issue.
> > However, I'm worried that this might burn that return type in stone,
> > not allowing us to improve it.  I say a macro, because at least with
> > a macro we'd have more chances of retrofitting a bool in the future,
> > since there would be no function pointers around.
> 
> One option would to just enable these function for gnu89 or higher.

Hmmm, sounds reasonable.  I guess anyone using -std=c89 is not
interested in this, anyway.  :)

> > Should I do a bunch of #ifdef to check for __plusplus, or do you have
> > a better way?  Ideally, I'd like to include <stdbool.h> form <string.h>,
> > but the standard doesn't allow it.  (Note to self: propose to fix that
> > in ISO C; standard headers should be allowed to include other standard
> > headers.)  I think GCC should accept _Bool in C++ mode.  It would save
> > us trouble.
> > 
> > Maybe a macro is fine for now?  Being a macro, we have more chances of
> > improving it later.
> > 
> >> This is not a complete review, I am still not sure about these new functions.
> >>
> >> [1] https://www.delorie.com/trybots/32bit/51346/ 
> > 
> > I think that's not the right link, is it?
> 
> Oops, indeed. It is https://www.delorie.com/trybots/32bit/51367/

Thanks!


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250901/c5295c02/attachment.sig>


More information about the Libc-alpha mailing list