Re: [PATCH 1/2] kernel.h: Add BUILD_BUG_ON_USED() macro.

From: Linus Torvalds
Date: Mon Nov 21 2011 - 23:36:08 EST


On Mon, Nov 21, 2011 at 5:31 PM, David Daney <ddaney.cavm@xxxxxxxxx> wrote:
>
> The GCC function attribute error("message") was added in version 4.3,
> so we define a new macro __linktime_error(message) to expand to this
> for GCC-4.3 and later.  This will give us an error diagnostic from the
> compiler on the line that fails.  For other compilers
> __linktime_error(message) expands to nothing, and we have to be
> content with a link time error, but at least we will still get a build
> error.

Ok. This looks quite reasonable, and I suspect we could replace some
of the other cases that currently use link-time errors with this and
get slightly better error reporting. It also looks like we should use
this __attribute__((__error__())) approach for our current
BUILD_BUG_ON() thing, instead of playing with the whole "negative
array size" thing.

And it does seem like glibc already uses this thing heavily, so we can
even expect it to work.

That said, I'm still not comfy actually applying these patches during
the -rc series. But for the next merge window, no problem.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/