【发布时间】:2012-01-12 09:43:23
【问题描述】:
在 C 中,函数声明可以是原型或非原型声明。例如,考虑以下最小程序:
int foo (); /* non-prototype declaration */
int bar (void); /* prototype declaration */
int main (int argc, char **argv)
{
return 0;
}
尽管在 C99 中非原型声明已过时,但我无法让 GCC 抱怨它们。例如,用 GCC 编译上述程序并启用所有错误即可成功:
$ gcc -std=c99 -pedantic -Werror -Wall test.c
$
有什么方法可以说服 GCC 对不是原型的函数声明发出警告?
(受an answer 启发的问题Keith Thompson。)
【问题讨论】:
标签: c gcc compilation compiler-warnings c99