[PATCH] array_length, array_end macros for internal use

Paul Eggert eggert@cs.ucla.edu
Sat Oct 21 18:10:00 GMT 2017


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.



More information about the Libc-alpha mailing list