summaryrefslogtreecommitdiff
path: root/lib/ccan/array_size/_info
blob: 56ba7998e41a09cf9851e52d0798714e1b01d3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <string.h>
#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 <ccan/array_size/array_size.h>
 *	#include <stdlib.h>
 *	#include <stdio.h>
 *
 *	// 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 (v2.1 or any later version)
 * Author: Rusty Russell <rusty@rustcorp.com.au>
 */
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;
}