INFO: Compiler Errors When Compiling a C++ File as a C File

Last reviewed: September 30, 1997
Article ID: Q104672

The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, 2.1, 4.0, 5.0

SUMMARY

The following error is typically the first of many returned by the Microsoft C/C++ Compiler when attempting to compile a file that includes a C++ header file such as IOSTREAM.H in a C program:

   ios.h(33) : error C2282: 'class' is followed by 'streambuf'.
            (missing ','?)

There may also be multiple C2054, C2085, C2143, and C2144 errors, and eventually a C1003 error indicating that the error count reached 100.

MORE INFORMATION

The C/C++ compiler invokes either the C compiler or the C++ compiler according to the file's extension. If it ends in .C, the C compiler is invoked; if it ends in .CPP or .CXX, the C++ compiler is invoked.

To invoke the C++ compiler on a file that ends in .C or some other extension, use the /Tp switch to explicitly specify a C++ source file.

The sample code below produces the above errors, if compiled with:

   cl hello.c

The code compiles fine if compiled with:

   cl hello.cpp

   -or-

   cl /Tp hello.c

Sample Code

   /* Compile options needed:  None
   */

   #include <iostream.h>

   void main (void)
   {
        cout << "Hello World";
   }


Additional query words: 8.00 8.00c 9.00 9.10
Keywords : CPPIss kbfasttip
Version : MS-DOS:7.0; WINDOWS:1.0,1.5,1.51,1.52; WINDOWS NT:1.0,2.0,2.1,4.0,5.0
Issue type : kbinfo


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: September 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.