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

Last reviewed: July 24, 1997
Article ID: Q42019
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, 6.0ax - Microsoft C for OS/2, versions 6.0, 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, 4.0, 5.0

SYMPTOMS

The compiler generates the following error:

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

   -or-

   fatal error C1057: unexpected end of file in macro expansion

CAUSE

This behavior is by design. It informs the user of a syntax error.

RESOLUTION

Examine the code line indicated by the compiler error. Ensure that the macro is used properly with both opening and closing parentheses and all parameters required.

MORE INFORMATION

Sample Code

The following sample code generates the error:

   /* 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 query words: 8.00 8.00c 9.00
Keywords : kbfasttip
Version : 6.0 6.0a 6.0ax 7.0 1.0 1.5 2.0 2
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.