On Wed, Apr 11, 2012 at 03:14:37AM -0600, Jim Cromie wrote:
> My larger goal was to find use-cases for this:
> (sent to LKML a day or 2 ago)
>
> +/**
> + * BUILD_BUG_DECL - check declared objects
> + * @name: distinguishes multiple uses at same scope.
> + * @cond: false expr, typically like sizeof(a) != sizeof(b)
> + *
> + * This works at file-scope too, and supports checks like:
> + * BUILD_BUG_DECL(foo, sizeof(a) != sizeof(b));
> + * BUILD_BUG_DECL(id_strings, ARRAY_SIZE(id_strings) != ARRAY_SIZE(id_vals));
> + */
> +#define BUILD_BUG_DECL(name, cond) \
> + static __initdata struct { \
> + int BUILD_BUG_DECL_ ## name[1 - 2*!!(cond)]; \
> + } BUILD_BUG_DECL_ ##name[0] __attribute__((unused))
> +
>
> It lets you check array consistency at compile-time,
> rather than waiting til run-time.
I don't see how this is an improvement over BUILD_BUG_ON() which
does the same thing.
regards,
dan carpenter
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel