PRB: Mixing Prototype Styles Incorrectly Generates C2059 Error

ID Number: Q61315

5.10 6.00 6.00a 6.00ax | 5.10 6.00

MS-DOS | OS/2

buglist5.10 buglist6.00 buglist6.00a buglist6.00ax fixlist7.00

Summary:

SYMPTOMS

If parameter list declarations are used with type list declarations

in a prototype, Microsoft C versions 5.1, 6.0, 6.0a, and 6.0ax will

generate a syntax error. Since ANSI does allow mixing declarators and

abstract declarators in the same prototype, this error message is

incorrect.

STATUS

Microsoft has confirmed this to be a problem in C versions 5.1, 6.0,

6.0a, and 6.0ax. This problem was corrected in C/C++ version 7.0.

More Information:

The sample code below may be used to illustrate this problem. The

following are suggested workarounds:

1. Prototype with a parameter list. For example:

void func(int x, float y);

2. Prototype with a type list. For example:

void func(int, float);

Sample Code

-----------

void func(int x, float); // Error C2059: Syntax Error ')'

void main(void)

{

int x=1, y=2;

func(x, y);

}

void func(int a, int b)

{

}