FIX: C2857 Error Incorrectly Generated Using /Yc Option (115707)



The information in this article applies to:

  • Microsoft C/C++ for MS-DOS 7.0
  • Microsoft Visual C++ 1.0
  • Microsoft Visual C++ 1.5
  • Microsoft Visual C++, 32-bit Editions 1.0
  • Microsoft Visual C++, 32-bit Editions 2.0
  • Microsoft Visual C++, 32-bit Editions 4.0
  • Microsoft Visual C++, 32-bit Editions 6.0

This article was previously published under Q115707

SYMPTOMS

If the /Yc option is used to create a precompiled header from a header file which contains a syntax error, as shown in the code below, the compiler will incorrectly generate the following error:
  error C2857: '#include' statement specified with the /Yctest.h
               command line option was not found in the source file
					
This error is generated after the header file syntax errors are listed and after all lines of the source file have been processed.

RESOLUTION

Correct the syntax errors contained in the header file.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed above. This bug was corrected in Visual C++ version 4.1.

MORE INFORMATION

The following code can be used to demonstrate this problem.

Sample Code

   /* Compile options needed: /Yctest.h /c
   */ 

TEST.H
------

   x int;  /* This file is intentionally given an error */ 
           /* to demonstrate the problem in the article */ 


TEST.CPP
--------

   #include "test.h"

   void main(void)
   {
   }
				

Modification Type:MinorLast Reviewed:7/5/2005
Keywords:kbbug kbCompiler kbCPPonly kbfix kbVC410fix KB115707