I'm learning "C" so I have installed Eclipse IDE and Cygwin compiler.
This is my code.
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
// return 0;
}
I have configured this options for Cygwin compiler "-O0 -g3 -Wall -Wextra -Werror -c -fmessage-length=0"
What bothers me is that I'm not getting any "warning" and it should say something about that missing "return" in an "int function".
I let here the console output
11:55:37 **** Incremental Build of configuration Debug for project HelloWorld ****
make all
Building file: ../main.c
Invoking: Cygwin C Compiler
gcc -O0 -g3 -Wall -Wextra -Werror -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
Finished building: ../main.c
Building target: HelloWorld.exe
Invoking: Cygwin C Linker
gcc -o "HelloWorld.exe" ./main.o
Finished building target: HelloWorld.exe
11:55:38 Build Finished. 0 errors, 0 warnings. (took 602ms)
Thanks guys :)
It's part of the standard. You don't have to (explicitly) return value in main function, so you don't get warning.
ISO/IEC 9899:TC2, 5.1.2.2.3 says:
(...)
reaching the } that terminates the main function returns a value of 0.
(...)