根据我正在阅读的内容,下面的代码是无效的 c99,但是我似乎能够使用 gcc -std=c99 编译它,据我所知应该禁用允许嵌入函数的 GNU 扩展。我似乎无法弄清楚为什么会这样。
int main() {
int e() {
printf("testing");
return 0;
};
e();
return 0;
}
最佳答案
为了获得关于不一致代码的警告,您还需要使用 -pedantic
标志,然后您将看到以下内容 ( see it live ):
warning: ISO C forbids nested functions [-Wpedantic]
int e() {
^
要将其转化为错误,您可以使用 -Werror
将警告转化为错误或使用 -pedantic-errors
。
来自 standards support 上的 gcc 文档:
to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings)
关于c - gcc 中的嵌套函数使用 -std=c99,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29108187/