Most of the people compile the C programs without this option .. Please try to avoid it.. That said, the mentioned option allows you to know the compiler warnings, dont skip it . ( I know in my previous post I didnt do it, but deliberately to show the mistake 🙂 )
compile.c look like this:
# include <stdio.h>
int main ()
{
printf ("\n I was told to compile ");
}
When I compile it with "-Wall" option I see:
[hchiramm@humbles-lap C-Pgm]$ gcc -Wall -c compile.c
compile.c: In function ‘main’:
compile.c:7:1: warning: control reaches end of non-void function [-Wreturn-type]
}
Why it so ? Any guess ?
hmmm.. I defined the function main() that it return "int", but I didnt do so.. Isnt it the same reason.. Lets try:
[hchiramm@humbles-lap C-Pgm]$ cat compile.c
# include <stdio.h>
int main ()
{
printf ("\n I was told to compile ");
return 0;
}
[hchiramm@humbles-lap C-Pgm]$ gcc -Wall -c compile.c
[hchiramm@humbles-lap C-Pgm]$
No Errors! .. Thats good.. so please remember to compile your program with "-Wall" option..