3 回答
TA贡献1816条经验 获得超6个赞
这是参数列表的旧式语法,它仍然被支持。在K&R C中,您还可以关闭类型声明,它们将默认为int。E.
main(argc, argv)char *argv[];{
return 0;}TA贡献1818条经验 获得超11个赞
void f(a)
float a; {
/* ... */}fdoublefloat
void f(float a);void f(a)
float a; {}doublefloat
// option 1void f(double a);void f(a)
float a; {}// option 2// this declaration can be put in a header, but is redundant in this case,
// since the definition exposes a prototype already if both appear in a
// translation unit prior to the call. void f(float a); void f(float a) {}TA贡献1844条经验 获得超8个赞
#include <stdio.h>int foo(c)int c;{ return printf("%d\n", c); }int bar(x)double x;{ return printf("%f\n", x); }int main(void){
foo(42); /* ok */
bar(42); /* oops ... 42 here is an `int`, but `bar()` "expects" a `double` */
return 0;}$ gcc proto.c $ gcc -Wstrict-prototypes proto.c proto.c:4: warning: function declaration isn’t a prototype proto.c:10: warning: function declaration isn’t a prototype $ ./a.out 42 0.000000
- 3 回答
- 0 关注
- 600 浏览
添加回答
举报
