Re: [PATCH 1/1] compiler.h: Add missing include statement for build_bug.h
From: Linus Torvalds
Date: Thu Nov 14 2024 - 13:28:32 EST
On Thu, 14 Nov 2024 at 09:42, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I think a better fix would be to not use BUILD_BUG_ON_ZERO() at all,
> but just use _Static_assert() directly here, to make
> <linux/compiler.h> be more self-sufficient.
Damn. We can't do that, because we typically use this in contexts that
require us to return zero (because the assertion part of an
expression), and then that whole expression needs to be a constant
integer expression.
And because _Static_assert() isn't an expression, we'd need to wrap it
with a statement expression or something.
And *hat* we can't do in arbitrary contexts.
Grr. I absolutely detest how bad the standard tools are. It's kind of
sad how we need to build our own hacky BUILD_BUG_ON() to do this.
There's probably some trick I'm missing, but yeah, it looks like we
need our BUILD_BUG_ON_ZERO() thing with that crazy bitfield hack.
Linus