Skip to content

Instantly share code, notes, and snippets.

@iori-yja
Created January 25, 2015 12:10
Show Gist options
  • Save iori-yja/310f3b69acdca75c0699 to your computer and use it in GitHub Desktop.
Save iori-yja/310f3b69acdca75c0699 to your computer and use it in GitHub Desktop.
21:09% cat g.c /tmp/test
#include <stdio.h>
int
main(void)
{
const int foo = 3;
char bar[foo];
for (int i = 0; i < foo; i ++) {
bar [i] = 0x30;
}
puts(bar);
return 0;
}
21:09% clang g.c /tmp/test
21:09% ./a.out /tmp/test
000
21:09% gcc g.c /tmp/test
g.c: In function ‘main’:
g.c:8:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < foo; i ++) {
^
g.c:8:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
21:10% gcc g.c -std=c11 /tmp/test
21:10% ./a.out /tmp/test
000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment