Re: Expose 'array_length()' macro in <sys/cdefs.h> or <sys/param.h>
From: Alejandro Colomar
Date: Wed Sep 30 2020 - 16:39:14 EST
On 2020-09-30 17:58, Joseph Myers wrote:
For some reason http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2529.pdf
doesn't seem to have reached the agenda of a WG14 meeting yet, but adding
a language feature like that to the standard would be another approach.
Hi Joseph,
Yes, that would be great!
I hope they add that to the language. When/if that happens, nitems()
could be `#define nitems(arr) _Lengthof(arr)` for std >= c2x.
In the meantime, I would add this macro to libc.
Maybe gcc could add such a great feature as an extension even before the
standard does...
Too many wishes :)
BTW, I sent a PATCH v4 that I should've sent --in-reply-to PATCH v3 in
this thread (but I forgot to do so); I'll link to it here:
https://sourceware.org/pipermail/libc-alpha/2020-September/117986.html
Thanks,
Alex