Commit 5b115ea9 authored by Rusty Russell's avatar Rusty Russell

foreach: fix HAVE_FOR_LOOP_DECLARATION case.

parent a2191edc
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* foreach - macro for simple iteration of arrays * foreach - macro for simple iteration of arrays
......
#if !HAVE_COMPOUND_LITERALS || !HAVE_FOR_LOOP_DECLARATION
#include <ccan/foreach/foreach.h> #include <ccan/foreach/foreach.h>
#if !HAVE_COMPOUND_LITERALS || !HAVE_FOR_LOOP_DECLARATION
#include <ccan/list/list.h> #include <ccan/list/list.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
for (unsigned _foreach_i = (unsigned long)((i) = (val), 0); \ for (unsigned _foreach_i = (unsigned long)((i) = (val), 0); \
(i); \ (i); \
(i) = ((FOREACH_TYPEOF(val)[]){(val), __VA_ARGS__, NULL}) \ (i) = ((FOREACH_TYPEOF(val)[]){(val), __VA_ARGS__, NULL}) \
[++_foreach_i]) \ [++_foreach_i], \
_foreach_no_nullval(_foreach_i, i, \ _foreach_no_nullval(_foreach_i, i, \
((void *[]){ val, __VA_ARGS__}))) ((void *[]){ val, __VA_ARGS__})))
#else /* !HAVE_FOR_LOOP_DECLARATION */ #else /* !HAVE_FOR_LOOP_DECLARATION */
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <ccan/tap/tap.h> #include <ccan/tap/tap.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <ccan/foreach/foreach.c> #include <ccan/foreach/foreach.c>
static int test_int_recursion(unsigned int level) static int test_int_recursion(unsigned int level)
......
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