【发布时间】:2015-06-02 23:54:18
【问题描述】:
我收到以下错误,什么是 std=c99/std=gnu99 模式?
源代码:
#include <stdio.h>
void funct(int[5]);
int main()
{
int Arr[5]={1,2,3,4,5};
funct(Arr);
for(int j=0;j<5;j++)
printf("%d",Arr[j]);
}
void funct(int p[5]) {
int i,j;
for(i=6,j=0;i<11;i++,j++)
p[j]=i;
}
Error Message:
hello.c: In function ‘main’:
hello.c:11:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j=0;j<5;j++)
^
hello.c:11:2: note: use option -std=c99 or -std=gnu99 to compile your code`
【问题讨论】:
-
您需要在 for 循环之外声明 j,或者使用 -std=c99 选项(如错误消息状态)进行编译。