我是一名开始学习 C 的 Linux 用户,我正在尝试编译我输入的源代码:
#include <stdio.h>
main()
{
float c,d;
c = 10215.3;
d = c / 3;
printf("%3.2f\n",d);
return 0;
}
它使用我编写的 makefile 编译:
cc -Wall -g printf.c -o printf
但我收到此警告:
printf.c:2:1: warning: return type defaults to ‘int’ [-Wreturn-type]
它编译代码,我得到了想要的输出,但我想了解这意味着什么
最佳答案
main()
应该是
int main()
在 C89 中,默认返回类型被假定为 int
,这就是它起作用的原因。
关于c - 警告 : return type defaults to ‘int’ [-Wreturn-type],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12373538/