INF: C2085 Error May Be the Result of a Missing Semicolon

ID Number: Q32776

5.00 5.10 6.00 6.00a 6.00ax | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, and 6.0ax, the

compiler may generate the following error:

C2085 'identifier': not in formal parameter list

CAUSE

This error frequently occurs when a semicolon (;) is missing at the

end of a function prototype.

RESOLUTION

Double-check to make sure all function prototypes end with a

semicolon.

More Information:

The following program demonstrates this error:

void foo(void)

void main(void)

{

}

When this code is compiled, the following errors occur:

error C2085: 'main' : not in formal parameter list

error C2143: syntax error : missing ';' before '{'

The C2085 error normally means that the listed parameter was declared

in a function definition for a nonexistent formal parameter, but the

error is misleading in this case. With no semicolon to mark the end of

the prototype, the compiler interprets the prototype as the start of a

function definition, and interprets the next line following the

prototype as if it were the first declaration within a function

definition.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax