K&R-style variadic functions
Walter Bright
newshound2 at digitalmars.com
Wed Jul 18 02:41:17 PDT 2012
On 7/16/2012 11:56 PM, Jacob Carlborg wrote:
> To my understanding this is legal C :
>
> int foo ();
>
> It's a K&R-style variadic functions, while their use is discouraged, they're
> still legal C.
Variadic functions, in order to work in C, need at least one parameter so that
varargs can work.
int foo();
declares a function with an unspecified parameter list, not a variadic one. It
is specified by a definition somewhere:
int foo(a,b)
int a;
int b;
{ ... }
somewhere.
If Dstep encounters the first declaration form, your options are to:
1. reject it (a perfectly reasonable approach)
2. treat it as:
int foo(void);
I suggest option 2, which is what C++ does.
More information about the Digitalmars-d
mailing list