lkml.org 
[lkml]   [2021]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 17/20] linux/array_size.h: Add __is_array(a) to help readability
On Sat, Nov 20, 2021 at 2:01 PM Alejandro Colomar
<alx.manpages@gmail.com> 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

\
 
 \ /
  Last update: 2021-11-21 14:23    [W:0.199 / U:0.884 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site