Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我error: 'for' loop initial declaration used outside C99 mode尝试用make. 我找到了一个wiki,上面写着
error: 'for' loop initial declaration used outside C99 mode
make
将 -std=c99 放入编译行:gcc -std=c99 foo.c -o foo
gcc -std=c99 foo.c -o foo
问题是我不知道如何在make. 我打开Makefile,找到CC = gcc并将其更改为CC = gcc -std=c99没有结果。有任何想法吗?
CC = gcc
CC = gcc -std=c99
将 CFLAGS=-std=c99 放在 Makefile 的顶部。
要在不使用 C99 的情况下消除错误,您只需在 for 循环所在的块的顶部声明迭代器变量。
代替:
for (int i = 0; i < count; i++) { }
采用:
int i; //other code for (i = 0; i < count; i++) { }