Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid bleeding edge ‘for’ loop initial declarations.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 28 Oct 2018 20:20:04 +0000 (21:20 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 28 Oct 2018 20:29:30 +0000 (21:29 +0100)
I suspect Travis to fail because cmake doesn't use -std=c11 with try_run.

tools/cmake/test_prog/prog_stacksetup.c

index 37a6335..5a167c3 100644 (file)
@@ -26,7 +26,8 @@ void handler(void)
 {
   char garbage[1024];
   auto int dummy;
-  for (int i = 0; i < 1024; i++)
+  int i;
+  for (i = 0; i < 1024; i++)
     garbage[i] = 'X';
   handler_addr = (char *) &dummy;
   swapcontext(&uc_handler, &uc_main);
@@ -39,7 +40,8 @@ int main(int argc, char *argv[])
   char *skbuf = (char *) malloc(sksize * 2 + 2 * sizeof(union alltypes));
   if (skbuf == NULL)
     exit(1);
-  for (int i = 0; i < sksize * 2 + 2 * sizeof(union alltypes); i++)
+  int i;
+  for (i = 0; i < sksize * 2 + 2 * sizeof(union alltypes); i++)
     skbuf[i] = 'A';
   char *skaddr = skbuf + sizeof(union alltypes);