6 * build_assert - routines for build-time assertions
8 * This code provides routines which will cause compilation to fail should some
9 * assertion be untrue: such failures are preferable to run-time assertions,
10 * but much more limited since they can only depends on compile-time constants.
12 * These assertions are most useful when two parts of the code must be kept in
13 * sync: it is better to avoid such cases if possible, but seconds best is to
14 * detect invalid changes at build time.
16 * For example, a tricky piece of code might rely on a certain element being at
17 * the start of the structure. To ensure that future changes don't break it,
18 * you would catch such changes in your code like so:
22 * #include <ccan/build_assert/build_assert.h>
29 * static char *foo_string(struct foo *foo)
31 * // This trick requires that the string be first in the structure
32 * BUILD_ASSERT(offsetof(struct foo, string) == 0);
36 * License: Public domain
37 * Author: Rusty Russell <rusty@rustcorp.com.au>
39 int main(int argc, char *argv[])
44 if (strcmp(argv[1], "depends") == 0)