Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: C++ User's Guide Oracle Solaris Studio 12.3 Information Library |
3. Using the C++ Compiler Options
6. Creating and Using Templates
9. Improving Program Performance
10. Building Multithreaded Programs
11.2 Libraries Provided With the C++ Compiler
11.2.1 C++ Library Descriptions
11.2.2 Accessing the C++ Library Man Pages
11.5 Statically Linking Standard Libraries
11.7 Replacing the C++ Standard Library
11.7.2 What Cannot Be Replaced
11.7.3 Installing the Replacement Library
11.7.4 Using the Replacement Library
11.7.5 Standard Header Implementation
11.7.5.1 Replacing Standard C++ Headers
11.7.5.2 Replacing Standard C Headers
12. Using the C++ Standard Library
Generally, two steps are involved in using a class library:
Include the appropriate header in your source code.
Link your program with the object library.
The C++ compiler provides two implementations of iostreams:
Classic iostreams. This term refers to the iostreams library shipped with the C++ 4.0, 4.0.1, 4.1, and 4.2 compilers, and earlier with the cfront-based 3.0.1 compiler. There is no standard for this library. It is available in libiostream.
Standard iostreams. This is part of the C++ standard library, libCstd, and is available only in standard mode. It is neither binary-compatible nor source-compatible with the classic iostreams library.
If you have existing C++ sources, your code might look like the following example, which uses classic iostreams.
// file prog1.cc #include <iostream.h> int main() { cout << "Hello, world!" << endl; return 0; }
The following example uses standard iostreams.
// file prog2.cc #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; }
The following command compiles and links prog2.cc into an executable program called prog2. The program is compiled in standard mode. libCstd, which includes the standard iostream library, is linked by default.
example% CC prog2.cc -o prog2
The so-called “Classic” iostreams is the original 1986 version of iostreams, which was replaced in the C++ standard. It is selected through the -library=rwtools7,iostream option. No two implementations of “classic” iostreams are the same, so apart from being obsolete, code using it is not portable. Note that this library and option will be discontinued in future Oracle Solaris Studio releases.
The RW Tools.h++ toolset provided with legacy Sun Studio and with Oracle Studio dates from the 1990's and has not been significantly updated since. It's time and date classes have serious issues regarding daylight savings time that cannot be fixed. (The functionality of this toolset is currently available in the C++ Standard and in open source libraries like BOOST.) RW Tools.h++ is selected by the -library=rwtools7 or -library=rwtools7_std options and will be discontinued in future Oracle Solaris Studio releases.
The following table shows the compiler options for linking the C++ libraries. See A.2.49 -library=l[,l...] for more information.
Table 11-2 Compiler Options for Linking C++ Libraries
|