DevarajA said:
I've been told that c99 forbids declarations of functions without return
type and defaulting them to return int.
Previous versions of C allowed you to leave out the return type of a
function. If you did so, it would assume that you meant to make the
function return int. This feature was called "implicit int", not
"default int".
C99 removed the "implicit int" feature, making it a "constraint
violation" to leave out the return type when declaring or defining a
function. As you should know, constraint violations must be detected by
the compiler, and at least one "diagnostic message" must be output. A
constraint violation does not mean that the compiler must refuse to
translate the program.
The C standard does not talk of "warnings" or "errors", but only of
"diagnostics". Both warnings and errors are types of diagnostics. If you
get a warning from your compiler, that is your diagnostic. A warning IS
a diagnostic message just as much as an error is. It's just that the
compiler writers decided that they could continue translation in that case.
So why compiling the following
code with 'gcc a.c -Wall -std=c99' only gives a few warnings?
You left out the code and the warnings, but I can imagine it says
something similar to this:
[sbiber@eagle c]$ cat a.c
main(){}
[sbiber@eagle c]$ gcc a.c -Wall -std=c99
a.c:1: warning: return type defaults to `int'
This compiler is behaving correctly. It diagnosed the constraint
violation by outputting a warning. End of story.