generator: Don't print variable unless the generator returned a value
[ccan] / ccan / generator / test / compile_fail-4.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <ccan/generator/generator.h>
5
6 #include <ccan/generator/generator.c>
7
8 #include "example-gens.h"
9
10 int main(int argc, char *argv[])
11 {
12         generator_t(int) g = gen1();
13 #ifdef FAIL
14         char *val;
15 #else
16         int val;
17 #endif
18
19         if (generator_next_val(val, g))
20                 printf("%d", val);
21
22         exit(0);
23 }