[PATCH] array_length, array_end macros for internal use
Florian Weimer
fweimer@redhat.com
Sat Oct 21 15:19:00 GMT 2017
I just encountered yet another case where I had to use the sizeof (A) /
sizeof (A[0]) idiom, so I wrote a general macro for it, with type
validation.
I put it into a separate header so that it can be used both from the
library and (non-internal) tests.
The macro as written is not compatible with C++ because it uses
__builtin_types_compatible_p for explicitness. If we need something
like this in C++ mode, we should write it as a (constexpr) template
function.
If accepted, I will commit the stdio-common subdirectory conversion
separately from the header, to simplify backports.
Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array_length.patch
Type: text/x-patch
Size: 18130 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171021/4566e3a6/attachment.bin>
More information about the Libc-alpha
mailing list