News for hackers. Stuff that matters.
Re:Why does this C program compile? by marcosdumay on Wednesday December 19, 2012 @05:58PM (#4945291)
I've just tried it. That code compiles without warnings by the default configuration of gcc version 4.4.5 (Debian 4.4.5-8) in my desktop (it's an up-to-date Debian Stable install).

If the default settings of gcc included throuwing out warnings for every time a function is declared without parameters and missing the void, lots of people would complain, and loud. It's a very common construct.

Re:Why does this C program compile? by kelnos on Thursday December 20, 2012 @01:01AM (#4946481)
Wow, that's crazy. I just tried it too (gcc 4.6.3). No warning options generate no warnings at all. -Wall only warns about the lack of return statement in main(). You only get the parameter-type default warning if you add -Wextra.

Interestingly, adding -std=c99 oddly removes the warning about the missing return statement in main().

I can't find a way to warn about the empty param list in the prototype, but it's possible that it's just not considered "bad enough style" to warrant one.

C++ is, of course, more strict. Try to compile that with g++, and you get several errors. The compiler needs to know how to mangle the symbol when it first encounters it, so you can't have "unspecified" parameter lists anywhere.