Article ID: 154419 - Last Review: March 19, 2008 - Revision: 5.0 Frequently asked questions about the Standard C++ libraryThis article was previously published under Q154419 On This PageSUMMARY This article presents a list of frequently asked questions
(FAQs) regarding the Standard C++ libraries and the answers to those questions.
For additional information regarding the Standard C++ Libraries, refer to the
ANSII Standard Specification and the MSDN Library. MORE INFORMATIONStandard C++ Libraries Frequently Asked QuestionsQ1: What does the Standard C++ library contain?A1: The Standard C++ library provides an extensible framework and contains components for language support, diagnostics, general utilities, strings, locales, standard template library (containers, iterators, algorithms, and numerics), and input/output. The Standard C++ library can be divided into the following categories:
Q2: What is the difference between C-Runtime library and Standard C++ library? What libraries will the Runtime library compiler options such as /ML, /MT, /MD, /MLd, /MTd, and /MDd include? A2: Visual C++ 5.0 and later include the following libraries in addition to the Microsoft Foundation Classes (MFC) libraries:
Collapse this table
Note MSVCPRT.lib and MSVCPRTD.lib are static libraries and do not have any dynamic link libraries (DLLs) directly related to them. These libraries are also dependent on MSVCRT.lib and MSVCRTD.lib, respectively. If you have any applications that use MSVCPRT.lib or MSVCPRTD.lib and you use the "Ignore Default Library" (/NOD or NODEFAULTLIB) option, be sure to link MSVCPRT.lib (or MSVCPRTD.lib) and MSVCRT.lib (or MSVCRTD.lib) with your application. Otherwise, you will get linker errors (LNK2001: unresolved externals in MSVCPRT.lib or MSVCPRTD.lib) when linking your application.) Depending on the headers you use in your code, a library from the Standard C++ library may also be linked. The header file <use_ansi.h> contains #pragma statements that force the Standard C++ library to be linked in. All Standard C++ headers include <use_ansi.h>: if you include any Standard C++ header in your application, the Standard C++ library will be linked by default. Standard C++ HeadersCollapse this table
Q3: How do I retain the old iostream functionality from Visual C++ .NET 2003 or from earlier versions of Visual C++ if I port my project from an earlier version? A3: If you want to retain the old iostream library (<iostream.h>), include one or more of the old iostream header files in your code. Do not use the new Standard C++ headers. You cannot mix calls to the old iostream library and the new Standard C++ library. Q4: How do I make the Standard C++ Libraries the default libraries for my application? A4: If you want to make the Standard C++ Libraries the default, include one or more of the new Standard C++ headers. Remember, you cannot mix calls to the old iostream and the new Standard C++ library. Existing libraries (static or dynamic link) that use old iostream functions will have to be modified to use Standard C++ library iostream functions. Q5: I want to use Standard C++ Libraries in a Microsoft Foundation Classes (MFC) application. Will this cause any conflicts with the C-Runtime Libraries? A5: No. MFC does not use any C-Runtime functions that will conflict with the Standard C++ Libraries. Q6: Why do I get error "error C2065: 'cout' : undeclared identifier" even though I have included <iostream>? A6: Standard C++ library is implemented in its own namespace "std". Make sure to add the statement Q7: Why am I getting "compiler error C2371: 'identifier' redefinition; different basic types"? A7:In versions of Visual C++ that are earlier than Visual C++ 2005, mixing Standard C++ headers and old iostream headers causes this error, even if they are included in different source files. The following are the different headers: Old iostream HeadersCollapse this table
Standard C++ HeadersCollapse this table
Q8: I have a project that was built with the "Ignore Default Libraries" option (/NOD or /NODEFAULTLIB). With Visual C++ 5.0 or later, I am getting linker error "LNK2001: unresolved external symbol 'symbol' ;" on all iostream function calls. What has changed? A8: The iostream functions have been removed from the C-Runtime library. If you are using the old iostream functions, you must add an additional library as follows: LIBCI.lib (single-threaded <ML>), LIBCIMT.lib (multithreaded <MT>), or MSVCIRT.lib (multithreaded dll <MD>). These libraries have been removed from Visual C++ 2005 and from later versions of Visual C++. If you are using the new iostream functions included with the Standard C++ library, you must add an additional library as follows: LIBCP.lib (single-threaded <ML>), LIBCPMT.lib (multithreaded <MT>), or MSVCPRT.lib (multithreaded dll <MD>). Do not mix different versions of the libraries. For example, if you are using the single-threaded version of the C-Runtime library, you must also use the single-threaded version of the old iostream library or Standard C++ library. You cannot mix calls to the old iostream library functions and the new Standard C++ library iostream functions. Q9: I am getting compiler warnings C4786 and/or C4788. None of the symbols in my program is anywhere near 255 characters in length. What is causing this? A9: C4786/C4788 is issued when a symbol's name exceeds 255 characters in length. This often happens with template class, and STL uses template class extensively. Ignoring this warning is usually safe. Use a #pragma warning (disable: 4786,4788) to suppress the messages. Q10: I am getting compiler warning "C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX." What does this mean? A10: Programs that use the Standard C++ library must be compiled with C++ exception handling enabled. C++ exception handling can be enabled by:
Q11: I am getting compiler error C2146, followed by C2065, and finally C2143, all pointing to the same line in my source. What does this mean? A11: This sequence of errors can be caused by the following type of construct: APPLIES TO
| Article Translations
|
Back to the top
