Microsoft KB Archive/32776

= PRB: C2085 Error May Be Caused by Missing Semicolon =

ID: Q32776

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50 | 1.00

MS-DOS                | OS/2       | WINDOWS   | WINDOWS NT kbtool kbfasttip kbprb

The information in this article applies to:

The Microsoft C/C++ Compiler (CL.EXE), included with:

- Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax - Microsoft C for OS/2, versions 6.0 and 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 - Microsoft Visual C++, 32-bit Edition, version 1.0

SYMPTOMS
An attempt to compile an application may fail and the compiler may generate the following message:

C2085 'identifier': not in formal parameter list

CAUSE
This error often indicates that a semicolon is missing from the end of a function prototype.

RESOLUTION
Verify that every function prototype ends with a semicolon. Microsoft C/C++ version 8.0 for Windows NT, which is included with Visual C++ version 1.0 for Windows NT, generates the following more descriptive message:

C2444 : 'myfunc' : used ANSI prototype, found 'type' expected '{' or ';' Microsoft C/C++ version 8.00c for MS-DOS, which is included with Visual C++ version 1.5 for Windows, gives a different error message which is also more descriptive:

C2240: unexpected 'void ' following formal list (only modifiers          are allowed)

MORE INFORMATION
The following code sample demonstrates this error:

Sample Code
void myfunc(void)

void main(void) { }

Compiling this cause produces the following messages:

error C2085: 'main' : not in formal parameter list error C2143: syntax error : missing ';' before '{' The C2085 error generally indicates that the listed parameter corresponds to a formal parameter not listed in the function definition, but the error is misleading in this case. Because no semicolon terminates the prototype, the compiler interprets the prototype as the first line of a function definition and interprets the next line as the first declaration in a function definition.

Additional reference words: 1.00 1.50 6.00 6.00a 6.00ax 7.00 8.00 8.00c KBCategory: kbtool kbfasttip kbprb KBSubcategory: CLIss

Last Reviewed: July 31, 1997