warning: return type defaults to ‘int’ [-Wimplicit-int]
时间: 2024-02-12 15:09:44 浏览: 55
这个警告信息是由于函数没有明确指定返回值类型,编译器默认将其返回类型设为 int。这个警告信息可能会导致意想不到的错误,因此建议在函数声明时显式指定返回类型,例如:
```
void functionName() {
// do something
}
```
应该改为:
```
int functionName() {
// do something
return 0;
}
```
这样可以避免一些编译错误,同时也使代码更易于理解。
相关问题
root@wei:/opt/rt6856_2013/RT288x_SDK/source# make menuconfig --> exit --> yes\(save\) Makefile:396: *** mixed implicit and normal rules: deprecated syntax /bin/sh: 1: /mipsel-linux-uclibc-gcc: not found /bin/sh: 1: /mipsel-linux-uclibc-gcc: not found lxtemp.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int] main() {} ^ /usr/bin/ld: cannot find -lncurses collect2: error: ld returned 1 exit status make[1]: *** [ncurses] Error 1 make: *** [menuconfig]Error 2 想在ubuntu16.04版本编译D-link 636l地bin文件错误如上我需要解决方法
根据提示,可能是缺少依赖库导致编译出错。
1. 首先,你需要安装交叉编译工具链 `mipsel-linux-uclibc-gcc`。
你可以通过以下命令安装:
```
sudo apt-get install gcc-mipsel-linux-gnu
```
2. 然后,你需要安装 `ncurses` 库。你可以通过以下命令安装:
```
sudo apt-get install libncurses5-dev
```
这应该会解决你的问题。如果问题仍然存在,请检查你的环境变量和交叉编译工具链路径是否正确。
warning:type specifier missing,defaults to 'int'
这个警告通常是因为在函数声明中,没有指定返回值类型。在C语言中,默认的返回值类型是int,但在现代的C编译器中,这种写法已经被视为过时的写法。为了避免这个警告,建议在函数声明时指定返回值类型,例如:
```c
float calculateAverage(int a, int b);
```
如果你不需要函数返回值,可以将返回值类型指定为void,例如:
```c
void printHello();
```