How to compile a C project in C99 mode?

后端 未结 4 2054
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 17:03

I got the following error message while compiling the C code:

error: \'for\' loop initial declarations are only allowed in C99 mode
note: use option -std=c9         


        
4条回答
  •  庸人自扰
    2020-12-14 17:56

    It means you can't declare variables in for statement.

    You should do:

    int i ;
    for( i = 0 ; i < len ; i++ )
    

    What you are probably doing

    for( int i = 0 ; i < len ; i++ )
    

提交回复
热议问题