PRB: C2144 Caused by Executable Code Between Declarations

ID Number: Q58559

3.00 4.00 5.00 5.10 6.00 6.00a 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C versions 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version

7.0, compiler error C2144 is defined as follows:

syntax error : missing 'token' before type 'type'

CAUSE

You may receive this error message if your program places

executable code before a data declaration, an acceptable practice

in Kernighan-and-Ritchie C. This practice has been outlawed in later

versions of the ANSI drafts.

This error message will normally occur if a required closing curly

brace (}), right parenthesis [)], or semicolon (;) is missing.

RESOLUTION

Placing all data declarations before all executable code corrects

the programming error.

More Information:

The following code demonstrates this error message:

/* Program : file.c */

#include <stdio.h>

void main(void)

{

int i;

printf("Beetlejuice\n");

int j;

}

Compiling this code with Microsoft C version 3.0, 4.0, 5.0, 5.1, 6.0,

6.0a, 6.0ax, or C/C++ version 7.0 or QuickC version 1.0, 1.01, 2.0, or

2.01 will return the following error message:

file.c

file.c(7) : error C2144: syntax error : missing ';' before

type 'int'

Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00