Re: [PATCH v2] <sys/param.h>: Add nitems() and snitems() macros
From: Alejandro Colomar
Date: Fri Sep 25 2020 - 13:46:09 EST
On 2020-09-25 19:39, Jonathan Wakely wrote:
> Yes, I'm aware of all the rationale. I already said that it makes
> sense in C++ where you have generic code. I am not convinced that it's
> necessary to add to <sys/param.h> when all it does is a cast from
> size_t to ptrdiff_t.
>
While I would prefer a signed version, I could live with only
'nitems()'. Having all the __must_be_array thing is the most important
part.
On 2020-09-25 19:42, Jonathan Wakely wrote:
On 25/09/20 18:30 +0200, Alejandro Colomar via Libstdc++ wrote:
I have a similar number of ARRAY_SIZE() and ARRAY_SSIZE().
I could have '#define snitems(arr) ((ptrdiff_t)nitems(arr))' in my
projects,
but is it really necessary?
The barrier for adding something to glibc headers should be a LOT
higher than "I could [do it in my own code], but is it really
necessary?"
Did I convince you? :-)
No.
Well, you convinced me :)
I'll rewrite the patch, and the problem about <stddef.h> will vanish.
Cheers,
Alex