K&R-style variadic functions

Paulo Pinto pjmlp at progtools.org
Tue Jul 17 11:07:08 PDT 2012


On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote:
> 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

K&R was more than that.

I guess most old timers here will agree with me that it was
not much more than glorified assembler in what concerns typing.

Much of the typing C has today, was actually brought in as part 
of the
ANSI C standardization process.

--
Paulo



More information about the Digitalmars-d mailing list