http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
提到
for ( declaration expression opt ; expression opt ) statement
Run Code Online (Sandbox Code Playgroud)
在6.8.5下的迭代语句.
这是一个错字或不C11有两个表达式,在最括号的循环?
这完全是关于语法的.6.8.5给出了两种形式的for循环:
for ( expressionopt ; expressionopt ; expressionopt ) statement
for ( declaration expressionopt ; expressionopt ) statement
Run Code Online (Sandbox Code Playgroud)
第二个版本指的是声明循环迭代器变量的情况,自C99以来是新的.
现在,如果我们看一下声明的语法意味着什么,可以在6.7中找到它:
declaration:
declaration-specifiers init-declarator-listopt ;
Run Code Online (Sandbox Code Playgroud)
注意末尾的分号 - 它需要分号作为语法的一部分.将语法复制/粘贴到for循环的第二个版本中,你得到这个:
for (declaration-specifiers init-declarator-listopt ; expressionopt ; expressionopt )
Run Code Online (Sandbox Code Playgroud)