Re: [PATCH v2 06/10] iio: adc: ad7476: Drop convstart chan_spec

From: Andy Shevchenko
Date: Fri Aug 08 2025 - 08:53:31 EST


On Fri, Aug 8, 2025 at 7:38 AM Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote:
> On 08/08/2025 00:16, Andy Shevchenko wrote:
> > On Thu, Aug 7, 2025 at 11:35 AM Matti Vaittinen
> > <mazziesaccount@xxxxxxxxx> wrote:

...

> >> + BUILD_BUG_ON(ARRAY_SIZE(st->channel) != ARRAY_SIZE(chip_info->channel));
> >
> > We have static_assert(). Why can't it be used?
>
> Don't know. Can you please enlighten me why one is preferred over the other?

Despite already made changes, I answer to this. The static_assert()
has at least two benefits over BUILD_BUG_ON():
- it can be declared in a global scope
- it produces more condensed (to the point) error message

That's why in general it's preferable over BUILD_BUG_ON().

--
With Best Regards,
Andy Shevchenko