Hi Paul,

On 2026-02-20T15:27:54-0800, Paul Eggert wrote:
> On 2026-02-20 15:09, Alejandro Colomar wrote:
> > +#define strnul(s)  strchr(s, '\0')
> 
> strnul should also be defined as a function.

Hmmm, okay; I thought it might be overkill, but we never know what
people will want to use as function pointers.  :)

> It shouldn't just be a
> type-generic macro. And once you've defined it as a function, the macro can
> call that function inside a _Generic wrapper (when the C compiler supports
> _Generic) so as to save a few bytes when the call to strnul/strchr isn't
> inlined.

So, you mean something like this?

        INLINE char *
        (strnul)(const char *s)
        {
                return strchr(s, '\0');
        }

        #define strnul(s)  strchr(s, '\0')


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to