PRB: Missing Closing ')' in Macro Causes Unexpected EOF

ID Number: Q42019

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

The Microsoft C version 5.1 Optimizing Compiler generates the

following error message when the compiler encounters an incomplete

macro invocation (missing closing parenthesis):

C1004: unexpected EOF

Microsoft C versions 6.0 and later generate the following error:

C1057 unexpected EOF in macro expansion ( missing ')'? )

CAUSE

This behavior is by design.

More Information:

The following sample code generates the error:

Sample Code:

------------

/* Compile options needed: none

*/

#include <stdio.h>

#define add(wx, wy) (wx) + (wy)

void main( )

{

int i;

i = add( 1, 2 );

printf( "i = %d\n", i );

i = add( 1, 2 ; /* missing ')' */

printf( "Hello World\n" );

for( i = 0; i < 10; i++ )

{

printf( "i + 10 = %d\n", add( i, 10 ) );

}

}

Additional reference words: 5.10 6.00 6.00a 6.00ax end of file 7.00