Hi Ben,

On Fri, Jan 09, 2026 at 10:35:24AM -0500, Ben Boeckel wrote:
> On Fri, Jan 09, 2026 at 13:07:34 +0100, Alejandro Colomar via Gcc wrote:
> > Is there a way to implement something like this?:
> > 
> >     #define strnulC(s)                           \
> >     ({                                           \
> >             static_assert(!has_side_effects(s)); \
> >             s + strlen(s);                       \
> >     })
> 
> `__builtin_constant_p` might be overly restrictive, but still helpful.

Because string APIs don't get constant expressions, I don't think it
would work in this case.  But a similar builtin might work.


Have a lovely day!
Alex

> 
> --Ben

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

Attachment: signature.asc
Description: PGP signature

Reply via email to