Microsoft KB Archive/115857

= PRB: Using #define to Specify Include File Fails with C2006 =

Article ID: 115857

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++ 5.0 Learning Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 4.0 Professional Edition

-



This article was previously published under Q115857



SYMPTOMS
When compiling the source below using precompiled headers, you may get the following error from the C/C++ compiler for MS-DOS under Windows:

error C2006: #include expected a filename, found 'identifier'

or the following error from the C/C++ compiler for MS-DOS under Windows NT:

fatal error C1001: internal compiler error

(compiler file 'msc1.cpp', line 585)

or the following errors when compiling with Microsoft Visual C++, 32-bit Edition, versions 1.0 and 2.0:

error C2006: #include expected a filename, found 'identifier'

fatal error C1001: INTERNAL COMPILER ERROR

(compiler file 'msc1.cpp', line 602)

Please choose the Technical Support command on the Visual Workbench Help menu, or open the Technical Support help file for more information

or the following errors when compiling with Microsoft Visual C++, 32-bit Edition, version 4.0,

error C2006: #include expected a filename, found 'identifier'

fatal error C1903: unable to recover from previous error(s); stopping execution



CAUSE
The problem is in using a defined constant to specify an include file in the #include directive. The directive is being processed before the macro is completely expanded, resulting in the error.



MORE INFORMATION
The following sample code can be used to demonstrate the problem.

Sample Code
/* Compile options needed: /Yu"stop.h" * Previously created with /Yc"stop.h" */

FIRST.H

 * 1) define SecondH "Second.H"

SECOND.H

 * 1) define SOMETHING

STOP.H
//This file is empty

TEST.CPP

 * 1) include "First.H"
 * 2) include SecondH
 * 3) include "stop.h"

Additional query words: 8.00 8.00c 9.00 1.00 1.50 2.00 4.00

Keywords: kbprb kbcompiler KB115857

-

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

© Microsoft Corporation. All rights reserved.