From 754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 16:54:15 +0930 Subject: lib: import ccan modules for tdb2 Imported from git://git.ozlabs.org/~ccan/ccan init-1161-g661d41f Signed-off-by: Rusty Russell --- lib/ccan/array_size/_info | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/ccan/array_size/_info (limited to 'lib/ccan/array_size/_info') diff --git a/lib/ccan/array_size/_info b/lib/ccan/array_size/_info new file mode 100644 index 0000000000..af7ef1cfd2 --- /dev/null +++ b/lib/ccan/array_size/_info @@ -0,0 +1,46 @@ +#include +#include +#include "config.h" + +/** + * array_size - routine for safely deriving the size of a visible array. + * + * This provides a simple ARRAY_SIZE() macro, which (given a good compiler) + * will also break compile if you try to use it on a pointer. + * + * This can ensure your code is robust to changes, without needing a gratuitous + * macro or constant. + * + * Example: + * // Outputs "Initialized 32 values" + * #include + * #include + * #include + * + * // We currently use 32 random values. + * static unsigned int vals[32]; + * + * int main(void) + * { + * unsigned int i; + * for (i = 0; i < ARRAY_SIZE(vals); i++) + * vals[i] = random(); + * printf("Initialized %u values\n", i); + * return 0; + * } + * + * License: LGPL (2 or any later version) + * Author: Rusty Russell + */ +int main(int argc, char *argv[]) +{ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/build_assert\n"); + return 0; + } + + return 1; +} -- cgit