我最近遇到了一个问题,下面的玩具示例使用以下方式编译clang -ansi
:
int main(void)
{
for (int i = 0; 0; );
return i;
}
Run Code Online (Sandbox Code Playgroud)
但是gcc -ansi
给出了以下错误:
a.c: In function ‘main’:
a.c:3:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
a.c:3:5: note: use option -std=c99 or -std=gnu99 to compile your code
Run Code Online (Sandbox Code Playgroud)
编译clang -ansi -pedantic
显示正在使用C99扩展名.
a.c:3:10: warning: variable declaration in for loop is a C99-specific feature [-pedantic,-Wc99-extensions]
for (int i = 0; 0; );
^
1 warning generated.
Run Code Online (Sandbox Code Playgroud)
clang允许哪些其他扩展-ansi
选项?我怎样才能禁用它们?