Tuesday, May 4, 2010

error: ‘for’ loop initial declarations are only allowed in C99 mode


Actually the complete error message will be like this.

error: ‘for’ loop initial declarations are only allowed in C99 mode,
note: use option -std=c99 or -std=gnu99 to compile your code

The one of many reason for this error message is, May be you have written a code like

for(int i=0;i<=10;i++)
{

}

The error is due to the declaration of variable i in the for loop. You have to declare the variable outside the for loop i.e.

int i;
for(i=0;i<=10;i++)
{
}


And most probably your error message will not come. Try this.
For more detail you can visit http://gcc.gnu.org/c99status.html




Delicious add to del.icio.us saved by 0 users

0 comments:

Post a Comment

 

Never feel bad if u loose some thing or do not get expected because "There is always a better option"