This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] array_length, array_end macros for internal use
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Sat, 21 Oct 2017 11:10:20 -0700
- Subject: Re: [PATCH] array_length, array_end macros for internal use
- Authentication-results: sourceware.org; auth=none
- References: <9c9b0fdf-5b87-7e58-0b0b-c8469e56c0a4@redhat.com>
Thanks, this is a good thing to write a macro for. A couple of comments:
The Emacs internals use the name ARRAYELTS for the same concept. I recall that
the name was discussed at some length when the macro was introduced. "length" is
perhaps not the best word to use here, since array_length ("foo") != strlen
("foo"). And capitalization is appropriate when a macro cannot be written as a
function. So I suggest the name ARRAYELTS, or something like it.
+#define array_end(var) &(var)[array_length (var)]
We haven't felt the need for such a macro in Emacs. If there's need in glibc,
the definiens should be parenthesized so that (mis?)uses like (& ARRAYEND
(var)->firstmember) are handled properly.