foreach: fix HAVE_FOR_LOOP_DECLARATION case.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 02:42:46 +0000 (13:12 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 02:42:46 +0000 (13:12 +1030)
ccan/foreach/_info
ccan/foreach/foreach.c
ccan/foreach/foreach.h
ccan/foreach/test/run-nested.c

index c49a9525d9cfc9261be3454f98125b7c8675bbfa..11f1b7321144b58a0a4d11126be83d745b67791f 100644 (file)
@@ -1,6 +1,6 @@
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
 
 /**
  * foreach - macro for simple iteration of arrays
index a18842b0979414f105e85a0ca943cbf63cb95517..70040ee986a5116bb407ea5ebc3ab703d51abd98 100644 (file)
@@ -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>
index 16471894c77cc241d2433c7ad66a7ab727c39088..c7e878f89c9fdc3877395220082f044a746dd09e 100644 (file)
@@ -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 */
index 13ab46678b6c6e1e9de83ff35394a886f29360a0..b54fbbe07bcd1b17f658aa76845850d298657f3b 100644 (file)
@@ -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)