Microsoft KB Archive/93447

= PRB: C2060 or C1004 Error Occurs Using TRY/CATCH Macros =

Article ID: 93447

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.51
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 4.1 Subscription
 * Microsoft Visual C++ 4.2 Professional Edition
 * Microsoft Visual C++ 5.0 Standard Edition

-



This article was previously published under Q93447



SYMPTOMS
When compiling a C++ program that uses the TRY and CATCH macros to implement exception handling, the compilation fails with the following error message:

error C2060: syntax error : end-of-file found

With Visual C++ 32-bit Edition, the following error is generated:

fatal error C1004: unexpected end of file found



CAUSE
A CATCH (or AND_CATCH) block is not closed with the END_CATCH macro. The CATCH macro creates a code block that is to be terminated by the END_CATCH macro.



RESOLUTION
Modify the program code to add the END_CATCH macro to the exception handling code.



Sample Code
/* Compile option needed: none if source file given .cpp extension, /Tp otherwise.


 * 1) include 
 * 2) include 

void main(void) {  TRY {  }   CATCH(CFileException,e) {  }   // Uncomment following line for successful compilation //END_CATCH }

Additional query words: 8.00 8.00c 9.00 9.10

Keywords: kbprb kbcompiler KB93447

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.