]> git.ozlabs.org Git - ponghero.git/blob - ccan/build_assert/_info.c
Add web pages.
[ponghero.git] / ccan / build_assert / _info.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * build_assert - routines for build-time assertions
7  *
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.
11  *
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.
15  *
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:
19  *
20  * Example:
21  *      char *foo_string(struct foo *foo)
22  *      {
23  *              // This trick requires that the string be first in the structure
24  *              BUILD_ASSERT(offsetof(struct foo, string) == 0);
25  *              return (char *)foo;
26  *      }
27  */
28 int main(int argc, char *argv[])
29 {
30         if (argc != 2)
31                 return 1;
32
33         if (strcmp(argv[1], "depends") == 0)
34                 /* Nothing. */
35                 return 0;
36
37         return 1;
38 }