K&R-style variadic functions
Regan Heath
regan at netmail.co.nz
Tue Jul 17 08:16:29 PDT 2012
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg <doob at me.com> wrote:
> On 2012-07-17 16:36, Regan Heath wrote:
>
>> I believe old-style no parameter function declarations MUST have "void"
>> i.e.
>>
>> int foo(void);
>
> That is still the case, regardless of "style"?
>
>> They cannot read:
>>
>> int foo();
>>
>> The latter MUST have parameters, we just can't tell what they are.
>
> Take a look at this:
>
> http://en.wikipedia.org/wiki/K%26R_C#KRC
>
> In that example none of the functions have any parameters declared and
> are not called with any arguments.
K&R C did not allow you to declare arguments at all, according to the wiki:
"Since K&R function declarations did not include any information about
function arguments, function parameter type checks were not performed,
although some compilers would issue a warning message if a local function
was called with the wrong number of arguments, or if multiple calls to an
external function used different numbers or types of arguments. Separate
tools such as Unix's lint utility were developed that (among other things)
could check for consistency of function use across multiple source files."
So all K&R function declarations were <name>() with no parameters.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list