Re: [PATCH v2 17/20] linux/array_size.h: Add __is_array(a) to help readability

From: Arnd Bergmann
Date: Sun Nov 21 2021 - 08:23:16 EST


On Sat, Nov 20, 2021 at 2:01 PM Alejandro Colomar
<alx.manpages@xxxxxxxxx> wrote:
>
> /* &a[0] degrades to a pointer: a different type from an array */
> -#define __must_be_array(a) __must_be(!__same_type((a), &(a)[0]))
> +#define __is_array(a) (!__same_type((a), &(a)[0]))
> +
> +#define __must_be_array(a) __must_be(__is_array(a))

I'd go the other way here if you want to improve this, and open-code it
to avoid nested macros. That produces more readable error messages
with recent compilers that try to unwind each macro one at a time.

Arnd