Re: is this definition old-style or new-style

From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 03/01/05


Date: Mon, 28 Feb 2005 17:56:08 -0800

Walter Roberson wrote:

> In article <1109532043.404507.62330@z14g2000cwz.googlegroups.com>,
> G Fernandes <ge.fernandes@gmail.com> wrote:
> :This below definition fits the description of a C89 and K&R style
> :definition (not valid in C99).
>
> :foo(length, factor, multiple) {/* body */}
>
> Wouldn't old style be:
>
> foo(length, factor, multiple) length, factor, multiple; { /* body */ }
> ...

C89/90 allows selective declaration of function parameters in
declaration list. You can declare all of them

  int foo(length, factor, multiple)
  int length, factor, multiple;
  { /* body */ }

you can declare none

  int foo(length, factor, multiple)
  { /* body */ }

you can declare only some of them

  int foo(length, factor, multiple)
  int factor;
  { /* body */ }

All these variants are fine in C89/90.

However, in C99 "old-style" function definitions are required to declare
all named parameters in declaration list, meaning that in C99 only the
first variant is valid.

-- 
Best regards,
Andrey Tarasevich