void func() { whatever; }
void func(void);
void func() { whatever; }
ISO/ANSI C always did (to denote "no parameters"). Apparently the compiler disabled silent fallback to pre-standard foo ...Apparently it does now want "void" everywhere.
You know, to get things going at first we assembled the hexcodes manually. Then we got an assembler. When C appeared, it was a great improvement - and you could still do the things you did before.K&R was fairly seriously lacking in terms of type safety.
Thanks for the clarification. I'll adapt.void func() in C is a function that takes any number and any type of arguments. It is only a declaration ("func is a function"), not a prototype ("func is a function taking such and such arguments"). It relies on programmer skill to have the same formal and actual arguments. If the programmer gets it wrong the compiler (and the link editor) can't produce an error message, and a runtime crash is likely.
If I remember that correctly, no.void func(void) in C is the equivalent of void func() in C++, a function taking no arguments. In both cases it is a prototype.
void foo()
is equivalent to void foo(...)
, while meaning void foo(void)
in C (my knowledge is likely outdated, it has been decades since I contributed to a C++ compiler). In C++, the argument list gets encoded into the symbol and you hit a link error. In C, not so. Where PMc is correct is that void can not be a named paramete. So no void foo(void uninteresting, int fd)
.If I remember that correctly, no.
In C++,void foo()
is equivalent tovoid foo(...)
, while meaningvoid foo(void)
in C (my knowledge is likely outdated, it has been decades since I contributed to a C++ compiler). In C++, the argument list gets encoded into the symbol and you hit a link error. In C, not so. Where PMc is correct is that void can not be a named paramete. So novoid foo(void uninteresting, int fd)
.