Mail Archives: djgpp/1997/12/28/15:00:08
> >>When I'm using the -Wall switch, I get also the warning about
> >>main, defaulting to 'int'...
>
> My declaration was: *main()* not *void main()*.
> main() indeed defaults to int main(), but the question was how to use the
> shortcut without being warned.
I suspect that before ANSI C, people would declare functions without
return types, and return *pointers*. Thus, the compiler is warning
you that it's defaulting to int in case you expected to return
something else with it (that might be a different size nowadays).
GCC's policy is that warnings are for cases where the compiler thinks
you might have made a mistake, but it's possible that you knew what
you were doing, and so it will do what it thinks is the right thing,
but warn you in case it's wrong. If it knows you made a mistake, it
issues an error instead.
- Raw text -