Not to be fixed
Created: Feb 22, 2016
Updated: Mar 4, 2016
Resolved Date: Feb 22, 2016
Found In Version: 8.0
Severity: Standard
Applicable for: Wind River Linux 8
Component/s: Userspace
root@qemu0:/# gcc -o hello hello.c
hello.c:7:1: warning: return type defaults to 'int' [-Wimplicit-int]
main() {
^
-----
According to upstream release note on porting to GCC 5.x:
<https://gcc.gnu.org/gcc-5/porting_to.html>
== C language issues ==
* Default standard is now GNU11
GCC defaults to -std=gnu11 instead of -std=gnu89. This brings several changes that users should be aware of. The following paragraphs describe some of these changes and suggest how to deal with them
...
* Some warnings are enabled by default
The C99 mode enables some warnings by default. For instance, GCC warns about missing declarations of functions:
int
foo (void)
{
return bar ();
}
This example now gives the following diagnostic:
w.c:4:10: warning: implicit declaration of function 'bar' [-Wimplicit-function-declaration]
return bar ();
^
To suppress this warning add the proper declaration:
int bar (void);
or use -Wno-implicit-function-declaration.
Another warning that is now turned on by default is the warning about implicit int, as in the following snippet:
foo (u)
{
return u;
}
This example now gives the following diagnostic:
q.c:1:1: warning: return type defaults to 'int' [-Wimplicit-int]
foo (u)
^
q.c: In function 'foo':
q.c:1:1: warning: type of 'u' defaults to 'int' [-Wimplicit-int]
To suppress this warning just add the proper types:
int
foo (int u)
{
return u;
}
or use -Wno-implicit or -Wno-implicit-int.
Another warning that is now turned on by default is the warning about returning no value in a function returning non-void:
int
foo (void)
{
return;
}
This example now gives the following diagnostic:
q.c:4:3: warning: 'return' with no value, in function returning non-void
return;
^
The fix is either to specify a proper return value, or to declare the return type of foo as void.
1)configure --enable-board=qemux86-64 --enable-kernel=standard --enable-rootfs=glibc-std --with-template=feature/target-toolchain
2)make fs
3)make start-target
root@qemu0:/# cat hello.c
#include <stdio.h>
main() {
printf("Hello World\n");
}
root@qemu0:/# gcc -o hello hello.c
hello.c:7:1: warning: return type defaults to 'int' [-Wimplicit-int]
main() {
^