Browse Source

foreach: fix HAVE_FOR_LOOP_DECLARATION case.

Rusty Russell 15 years ago
parent
commit
5b115ea939
4 changed files with 4 additions and 3 deletions
  1. 1 1
      ccan/foreach/_info
  2. 1 1
      ccan/foreach/foreach.c
  3. 1 1
      ccan/foreach/foreach.h
  4. 1 0
      ccan/foreach/test/run-nested.c

+ 1 - 1
ccan/foreach/_info

@@ -1,6 +1,6 @@
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
 
 /**
  * foreach - macro for simple iteration of arrays

+ 1 - 1
ccan/foreach/foreach.c

@@ -1,5 +1,5 @@
-#if !HAVE_COMPOUND_LITERALS || !HAVE_FOR_LOOP_DECLARATION
 #include <ccan/foreach/foreach.h>
+#if !HAVE_COMPOUND_LITERALS || !HAVE_FOR_LOOP_DECLARATION
 #include <ccan/list/list.h>
 #include <stdint.h>
 #include <stdlib.h>

+ 1 - 1
ccan/foreach/foreach.h

@@ -46,7 +46,7 @@
 	for (unsigned _foreach_i = (unsigned long)((i) = (val), 0);	\
 	     (i);							\
 	     (i) = ((FOREACH_TYPEOF(val)[]){(val), __VA_ARGS__, NULL})	\
-		     [++_foreach_i])					\
+		     [++_foreach_i],					\
 		_foreach_no_nullval(_foreach_i, i,			\
 				    ((void *[]){ val, __VA_ARGS__})))
 #else /* !HAVE_FOR_LOOP_DECLARATION */

+ 1 - 0
ccan/foreach/test/run-nested.c

@@ -2,6 +2,7 @@
 #include <ccan/tap/tap.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <ccan/foreach/foreach.c>
 
 static int test_int_recursion(unsigned int level)