westfw:
a function prototype such as foo(); means that the arguments are undefined
Hmm. I think you'll get errors in most modern C implementations.
Technically, "void foo();" will be a valid prototype for an "old-style" C function
void foo(a,b, c)
int a; char b; double c;
{
printf("%3.3f\n", abc);
}
But DON'T DO THOSE!!! gcc gives an error if you have the above prototype with a modern function:
void foo( int a, char b, double c)
{
printf("%3.3f\n", abc);
}
K&C C before the ANSI X3J11 committee did not have prototypes at all. It only had the old style declarations. However, in the old style declarations, you had the implicit conversions happening. So any char or short argument are converted implicitly to int, and float arguments are converted to double. Here is the wording from the C99 standard:
If the expression that denotes the called function has a type that does not include a
prototype, the integer promotions are performed on each argument, and arguments that
have type float are promoted to double. These are called the default argument
promotions. If the number of arguments does not agree with the number of parameters,
the behavior is undefined.
C++ being a language to improve upon C required the user to always prototype his/her function.
During the initial process which lead up to the 1989 ANSI C standard which was replaced by the 1990 ISO C standard (*), we (**) took prototypes from the C++ language (as well as the way of declaring const/volatile, though const is slightly different between C/C++). However:
void foo ();
already had a meaning in C, of declaring foo as a function returning nothing, but nothing was said about the arguments, while in C++, it meant you were saying that foo did not take any arguments.. So we added the use of void to explicitly say that foo has no arguments. Later when C++ got standardized, it imported the use of void from C back into its languages.
During the standardization process, we tended to call the rule where the compiler creates a prototype for you the Miranda rule, modifying the US Miranda rule (you have the right to an lawyer, if you can not afford one, one will be appointed by the court) to be you have the right to a prototype, if you cannot afford a prototype, one will be appointed to by the compiler (hey what can I say, things get a little punchy when you are with the same people for 4-5 days a time).
While I know that I can avoid the void in the Arduino context, since you are always dealing with C++, I tend to always use void just because I am a C guy.
(*) ANSI is an American (US) standards body. After the ANSI C standard came out, it was promoted to be an ISO standard which is the world wide standards body. So while people talk about ANSI C, it is more correct now to say ISO C.
(**) I was on the original X3J11 standard committee, and was one of 3 members that was at the original meeting in 1983 to begin the standards process and who was still on the committee by the time the 1989 and 1990 standards came out. Originally I represented the Data General corporation (where I had written most of the DG C front end for the MV/Eclipse computers), and later the Open Software Foundation. When I moved on to Cygnus Solutions, I dropped out of the standards process, but I had been in it for 10 1/2 years.