somenath said:
On Jan 31, 9:21 am, Jack Klein <
[email protected]> wrote:
Thanks for the replies . But I am confused by your statement
"accepting an unspecified, but fixed,
argument list."
Are you indicating type of the arguments are unspecified but the
number of argument is specified If it is is fixed is it none ?
The term "fixed" is causing you problems so lets avoid it. The
declaration Jack Klein gave states that we don't know how many
arguments f needs. The compiler can not check the call (nore can it
do any type conversion other than what are called "the default
argument promotions") so you are on your own. This does not mean that
call can't be wrong, just that the compiler can't check it!
In particular, the declaration
void f();
does not mean that the function f can be called with a variable number
of arguments (like printf can). All it means is that the compiler
does not know (at this point) how many arguments are needed. To find
out, one must look at the *definition* of f. This may be in another
file. I may not even be available (if f is in a closed source
library) but only the actual definition can tell us how many arguments
f needs. When you find it, you will see something like:
void f() {...} /* f takes no arguments (old form) */
void f(void) {...} /* f takes no arguments (newer form) */
void f(int a) {...} /* f takes a single int */
If the call you make has the wrong number of arguments (as
specified in the *definition*) then the behaviour is undefined.
Note that I left out one option for f. If f is defined like this:
void f(int a, ...) {...}
then the behaviour is undefined. What this means is that one can only
call a function with a variable argument list if a prototype
declaration for it is in scope. This is why Jack Klein said "fixed".
The declaration 'void f();' does not say *how* many arguments must be
passed but it *does* prevent there being a variable number of them.
We don't know how many, but it is some "fixed" number.
All of this is rather esoteric since (except in the oddest of
situations) one would specify the number and type of a function's
arguments by writing a full function prototype.