Commit cbd27e92 authored by Rusty Russell's avatar Rusty Russell

alignof, array_size, crc: provide comments to allow testing examples.

parent 5378c864
......@@ -19,10 +19,13 @@
* #include <stdlib.h>
* #include <ccan/alignof/alignof.h>
*
* // Output contains "ALIGNOF(char) == 1"
* // Will also print out whether an onstack char array can hold a long.
* int main(int argc, char *argv[])
* {
* char arr[sizeof(int)];
*
* printf("ALIGNOF(char) == %zu\n", ALIGNOF(char));
* if ((unsigned long)arr % ALIGNOF(int)) {
* printf("arr %p CANNOT hold an int\n", arr);
* exit(1);
......
......@@ -12,17 +12,21 @@
* 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];
*
* static void init_values(void)
* 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)
......
......@@ -15,6 +15,7 @@
* #include <stdio.h>
* #include <stdlib.h>
*
* // Given IHATEMATH outputs 0x98a3b8df
* int main(int argc, char *argv[])
* {
* if (argc != 2) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment