On Mon, 2009 Jan 19 18:23:05 +0000, Nick Treleaven wrote:
- Various cases of foo() --> foo(void). (Come on guys... the only excuse is if you're older than dirt and still haven't broken your old K&R habits :)
Or you are used to C++ or C99 ;-) My brain keeps saying the 'void' is redundant. But I updated my function snippet a while ago to do it for me usually.
It never hurts to make it explicit. In C, a prototype with empty parens is sort of like a "wildcard" that will be consistent with any same-named function prototype/definition that actually does give the formal params. That's something one would use if s/he (A) didn't know what the real formal params were, as in syscalls that take a void* or a char* depending on platform, or (B) were too lazy to care ^_^ It's good to just put "void" in there to make clear that neither of these is going on.
But the real problem is that gcc doesn't warn about it (or I haven't found an option for gcc 4.1 anyway).
-Wstrict-prototypes :-) The warning it gives you is "function declaration isn’t a prototype".
--Daniel