Re: union: was: Re: [PATCH printk v1 05/18] printk: Add non-BKL console basic infrastructure
From: Steven Rostedt
Date: Tue Mar 28 2023 - 09:47:33 EST
On Tue, 28 Mar 2023 11:48:06 +0206
John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
> > static_assert(sizeof(struct cons_state) == sizeof(atomic_long_t));
>
> I never realized the kernel code was allowed to have that. But it is
> everywhere! :-) Thanks. I've added and tested the following:
I didn't know about static_assert(), as I always used BUILD_BUG_ON().
The difference being that BUILD_BUG_ON() has to be used within a function,
where as static_assert() can be done outside of functions. Hmm, maybe I can
convert some of my BUILD_BUG_ON()s to static_assert()s.
Learn something new every day.
-- Steve