Re: [PATCH 5/5 ver2] debug: BUILD_BUG_ON: error on non-const expressions

From: Jan Beulich
Date: Tue Sep 02 2008 - 12:09:53 EST


>>> Boaz Harrosh <bharrosh@xxxxxxxxxxx> 02.09.08 17:57 >>>
>-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
>+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
>+
>+/* Force a compilation error if condition is true */
>+#define BUILD_BUG_ON(e) \
>+ do { struct {int:-!!(e); } x __maybe_unused;} while(0)

As indicated before, you should at the very least use __x as the variable
name.

But didn't you have reservations against using a bitfield here? Or was it
really just the void cast on the sizeof() that you disliked?

Jan

--
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/