3 ms·
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) +#define BUILD_BUG_ON_NUL
by thomasahle 10y ago
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
The commit that introduced the notation, actually used something similar to your second approach:
https://github.com/torvalds/linux/commit/8c87df457cb58fe75b9b893007917cf8095660a0#diff-23e29fa8c20b4af09028e20e4131f1f5L687 https://github.com/torvalds/linux/commit/8c87df457cb58fe75b9...