3 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4 <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++, libg++, STL">
5 <meta name="DESCRIPTION" content="FAQ for the GNU libstdc++ effort.">
6 <title>libstdc++-v3 FAQ</title>
7 <link rel="StyleSheet" href="../lib3styles.css">
9 ** Locations of "the most recent snapshot is the Nth" text are
10 ** answers 1_1, 1_4, 4_1, 5_6.
15 <h1 class="centered">libstdc++ Frequently Asked Questions</h1>
17 <p>The latest version of this document is always available at
18 <a href="http://gcc.gnu.org/onlinedocs/libstdc++/faq/">
19 http://gcc.gnu.org/onlinedocs/libstdc++/faq/</a>.</p>
21 <p>To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</a>.
23 <!-- ####################################################### -->
27 <li><a href="#1_0">General Information</a>
28 <!-- I suspect these will mostly be links to/into existing documents. -->
30 <li><a href="#1_1">What is libstdc++-v3?</a>
31 <li><a href="#1_2">Why should I use libstdc++?</a>
32 <li><a href="#1_3">Who's in charge of it?</a>
33 <li><a href="#1_4">How do I get libstdc++?</a>
34 <li><a href="#1_5">When is libstdc++ going to be finished?</a>
35 <li><a href="#1_6">How do I contribute to the effort?</a>
36 <li><a href="#1_7">What happened to libg++? I need that!</a>
37 <li><a href="#1_8">What if I have more questions?</a>
38 <li><a href="#1_9">What are the license terms for libstdc++-v3?</a>
41 <li><a href="#2_0">Installation</a>
43 <li><a href="#2_1">How do I install libstdc++-v3?</a>
44 <li><a href="#2_2">[removed]</a>
45 <li><a href="#2_3">What is this CVS thing that you keep
47 <li><a href="#2_4">How do I know if it works?</a>
48 <li><a href="#2_5">This library is HUGE! And what's libsupc++?</a>
51 <li><a href="#3_0">Platform-Specific Issues</a>
53 <li><a href="#3_1">Can libstdc++-v3 be used with <my
54 favorite compiler>?</a>
55 <li><a href="#3_2">[removed]</a>
56 <li><a href="#3_3">Building under DEC OSF kills the assembler</a>
57 <li><a href="#3_4">I can't use 'long long' on Solaris</a>
60 <li><a href="#4_0">Known Bugs and Non-Bugs</a>
62 <li><a href="#4_1">What works already?</a>
63 <li><a href="#4_2">Bugs in gcc/g++ (not libstdc++-v3)</a>
64 <li><a href="#4_3">Bugs in the C++ language/lib specification</a>
65 <li><a href="#4_4">Things in libstdc++ that look like bugs</a>
67 <li><a href="#4_4_iostreamclear">reopening a stream fails</a>
68 <li><a href="#4_4_Weff">-Weffc++ complains too much</a>
69 <li><a href="#4_4_rel_ops">"ambiguous overloads"
70 after including an old-style header</a>
71 <li><a href="#4_4_interface">The g++-3 headers are
72 <strong>not ours</strong></a>
73 <li><a href="#4_4_glibc">compilation errors from streambuf.h</a>
74 <li><a href="#4_4_checks">errors about <em>*Cconcept</em> and
75 <em>constraints</em> in the STL...</a>
77 <li><a href="#4_5">Aw, that's easy to fix!</a>
80 <li><a href="#5_0">Miscellaneous</a>
82 <li><a href="#5_1">string::iterator is not char*;
83 vector<T>::iterator is not T*</a>
84 <li><a href="#5_2">What's next after libstdc++-v3?</a>
85 <li><a href="#5_3">What about the STL from SGI?</a>
86 <li><a href="#5_4">Extensions and Backward Compatibility</a>
87 <li><a href="#5_5">[removed]</a>
88 <li><a href="#5_6">Is libstdc++-v3 thread-safe?</a>
89 <li><a href="#5_7">How do I get a copy of the ISO C++ Standard?</a>
90 <li><a href="#5_8">What's an ABI and why is it so messy?</a>
97 <!-- ####################################################### -->
99 <h1><a name="1_0">1.0 General Information</a></h1>
100 <!-- I suspect these will mostly be links to/into existing documents. -->
101 <h2><a name="1_1">1.1 What is libstdc++-v3?</a></h2>
102 <p>The GNU Standard C++ Library v3, or libstdc++-2.9x, is an
103 ongoing project to implement the ISO 14882 Standard C++ library
104 as described in chapters 17 through 27 and annex D. As the
105 library reaches stable plateaus, it is captured in a snapshot
106 and released. The current release is
107 <a href="http://gcc.gnu.org/libstdc++/download.html">the
108 eleventh snapshot</a>. For those who want to see exactly how
109 far the project has come, or just want the latest
110 bleeding-edge code, the up-to-date source is available over
111 anonymous CVS, and can even be browsed over the Web (see below).
113 <p>A more formal description of the V3 goals can be found in the
114 official <a href="../17_intro/DESIGN">design document</a>.
118 <h2><a name="1_2">1.2 Why should I use libstdc++?</a></h2>
119 <p>The completion of the ISO C++ standardization gave the
120 C++ community a powerful set of reuseable tools in the form
121 of the C++ Standard Library. However, all existing C++
122 implementations are (as the Draft Standard used to say)
123 "incomplet and incorrekt," and many suffer from
124 limitations of the compilers that use them.
126 <p>The GNU C/C++/FORTRAN/<pick-a-language> compiler
127 (<code>gcc</code>, <code>g++</code>, etc) is widely considered to be
128 one of the leading compilers in the world. Its development
129 has recently been taken over by the
130 <a href="http://gcc.gnu.org/">GCC team</a>. All of
131 the rapid development and near-legendary
132 <a href="http://gcc.gnu.org/gcc-2.95/buildstat.html">portability</a>
133 that are the hallmarks of an open-source project are being
134 applied to libstdc++.
136 <p>That means that all of the Standard classes and functions
137 (such as <code>string</code>, <code>vector<></code>, iostreams,
138 and algorithms) will be freely available and fully compliant.
139 Programmers will no longer need to "roll their own"
140 nor be worried about platform-specific incompatabilities.
144 <h2><a name="1_3">1.3 Who's in charge of it?</a></h2>
145 <p>The libstdc++ project is contributed to by several developers
146 all over the world, in the same way as GCC or Linux.
147 Benjamin Kosnik, Gabriel Dos Reis, Phil Edwards, and Ulrich
148 Drepper are the lead maintainers of the CVS archive.
150 <p>Development and discussion is held on the libstdc++ mailing
151 list. Subscribing to the list, or searching the list
152 archives, is open to everyone. You can read instructions for
153 doing so on the <a href="http://gcc.gnu.org/libstdc++/">homepage</a>.
154 If you have questions, ideas, code, or are just curious, sign up!
158 <h2><a name="1_4">1.4 How do I get libstdc++?</a></h2>
159 <p>The eleventh (and latest) snapshot of libstdc++-v3 is
160 <a href="http://gcc.gnu.org/libstdc++/download.html">available via
161 ftp</a>. The filename is libstdc++-2.92.tar.gz.
163 <p>The <a href="http://gcc.gnu.org/libstdc++/">homepage</a>
164 has instructions for retrieving the latest CVS sources, and for
165 browsing the CVS sources over the web.
167 <p>The subset commonly known as the Standard Template Library
168 (chapters 23 through 25, mostly) is adapted from the final release
173 <h2><a name="1_5">1.5 When is libstdc++ going to be finished?</a></h2>
174 <!-- <p>Nathan Myers gave the best of all possible answers in <A
175 href="http://www.deja.com/getdoc.xp?AN=469581698&fmt=text">a
176 Usenet article</a>.</p>
177 which is no longer available, thanks deja...-->
178 <p>Nathan Myers gave the best of all possible answers, responding to a
179 Usenet article asking this question: <em>Sooner, if you help.</em>
183 <h2><a name="1_6">1.6 How do I contribute to the effort?</a></h2>
184 <p>Here is <a href="../17_intro/contribute.html">a
185 page devoted to this topic</a>. Subscribing to the mailing
186 list (see above, or the homepage) is a very good idea if you
187 have something to contribute, or if you have spare time and
188 want to help. Contributions don't have to be in the form of
189 source code; anybody who is willing to help write
190 documentation, for example, or has found a bug in code that
191 we all thought was working, is more than welcome!
195 <h2><a name="1_7">1.7 What happened to libg++? I need that!</a></h2>
196 <p>The most recent libg++ README states that libg++ is no longer
197 being actively maintained. It should not be used for new
198 projects, and is only being kicked along to support older code.
200 <p>The libg++ was designed and created when there was no Standard
201 to provide guidance. Classes like linked lists are now provided
202 for by <code>list<T></code> and do not need to be created by
203 <code>genclass</code>. (For that matter, templates exist now and
204 are well-supported, whereas genclass (mostly) predates them.)
206 <p>There are other classes in libg++ that are not specified in the
207 ISO Standard (e.g., statistical analysis). While there are a
208 lot of really useful things that are used by a lot of people
209 (e.g., statistics :-), the Standards Committee couldn't include
210 everything, and so a lot of those "obvious" classes
213 <p>Since libstdc++ is an implementation of the Standard Library, we
214 have no plans at this time to include non-Standard utilities
215 in the implementation, however handy they are. (The extensions
216 provided in the SGI STL aren't maintained by us and don't get
217 a lot of our attention, because they don't require a lot of our
218 time.) It is entirely plausable that the "useful stuff"
219 from libg++ might be extracted into an updated utilities library,
220 but nobody has stated such a project yet.
222 <!-- The advertisement, so to speak, might have to go. Hmmmmm. -->
223 <p>(The <a href="http://www.boost.org/">Boost</a> site houses free
224 C++ libraries that do varying things, and happened to be started
225 by members of the Standards Committee. Certain "useful
226 stuff" classes will probably migrate there.)
228 <p>For the bold and/or desperate, the
229 <a href="http://gcc.gnu.org/fom_serv/cache/33.html">GCC FAQ</a>
230 describes where to find the last libg++ source.
234 <h2><a name="1_8">1.8 What if I have more questions?</a></h2>
235 <p>If you have read the README and RELEASE-NOTES files, and your
236 question remains unanswered, then just ask the mailing list.
237 At present, you do not need to be subscribed to the list to
238 send a message to it. More information is available on the
239 homepage (including how to browse the list archives); to send
240 to the list, use <a href="mailto:libstdc++@gcc.gnu.org">
241 <code>libstdc++@gcc.gnu.org</code></a>.
243 <p>If you have a question that you think should be included here,
244 or if you have a question <em>about</em> a question/answer here,
245 contact <a href="mailto:pme@gcc.gnu.org">Phil Edwards</a>
246 or <a href="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</a>.
250 <h2><a name="1_9">1.9 What are the license terms for libstdc++-v3?</a></h2>
251 <p>See <a href="../17_intro/license.html">our license description</a>
252 for these and related questions.
256 <h1><a name="2_0">2.0 Installation</a></h1>
257 <h2><a name="2_1">2.1 How do I install libstdc++-v3?</a></h2>
258 <p>Complete instructions are not given here (this is a FAQ, not
259 an installation document), but the tools required are few:
262 <li> A 3.x release of GCC. Note that building GCC is much
263 easier and more automated than building the GCC 2.[78]
264 series was. If you are using GCC 2.95, you can still
265 build earlier snapshots of libstdc++.
266 <li> GNU Make is recommended, but should not be required.
267 <li> The GNU Autotools are needed if you are messing with
268 the configury or makefiles.
270 <p>The file <a href="../documentation.html">documentation.html</a>
271 provides a good overview of the steps necessary to build, install,
272 and use the library. Instructions for configuring the library
273 with new flags such as --enable-threads are there also, as well as
274 patches and instructions for working with GCC 2.95.
276 <p>The top-level install.html and
277 <a href="../17_intro/RELEASE-NOTES">RELEASE-NOTES</a> files contain
278 the exact build and installation instructions. You may wish to
279 browse those files over CVSweb ahead of time to get a feel for
280 what's required. RELEASE-NOTES is located in the
281 ".../docs/17_intro/" directory of the distribution.
285 <h2><a name="2_2">2.2 [removed]</a></h2>
286 <p>This question has become moot and has been removed. The stub
287 is here to preserve numbering (and hence links/bookmarks).
291 <h2><a name="2_3">2.3 What is this CVS thing that you
292 keep mentioning?</a></h2>
293 <p>The <em>Concurrent Versions System</em> is one of several revision
294 control packages. It was selected for GNU projects because it's
295 free (speech), free (beer), and very high quality. The <A
296 href="http://www.gnu.org/software/cvs/cvs.html">CVS entry in
297 the GNU software catalogue</a> has a better description as
299 <a href="http://www.cvshome.org/">link to the makers of CVS</a>.
301 <p>The "anonymous client checkout" feature of CVS is
302 similar to anonymous FTP in that it allows anyone to retrieve
303 the latest libstdc++ sources.
305 <p>After the first of April, American users will have a
306 "/pharmacy" command-line option...
307 <!-- wonder how long that'll live -->
311 <h2><a name="2_4">2.4 How do I know if it works?</a></h2>
312 <p>libstdc++-v3 comes with its own testsuite. You do not need
313 to actually install the library ("<code>make
314 install</code>") to run the testsuite.
316 <p>To run the testsuite on the library after building it, use
317 "make check" while in your build directory. To run
318 the testsuite on the library after building and installing it,
319 use "make check-install" instead.
321 <p>If you find bugs in the testsuite programs themselves, or if you
322 think of a new test program that should be added to the suite,
323 <strong>please</strong> write up your idea and send it to the list!
327 <h2><a name="2_5">2.4 This library is HUGE! And what's libsupc++?</a></h2>
328 <p>Usually the size of libraries on disk isn't noticeable. When a
329 link editor (or simply "linker") pulls things from a
330 static archive library, only the necessary object files are copied
331 into your executable, not the entire library. Unfortunately, even
332 if you only need a single function or variable from an object file,
333 the entire object file is extracted. (There's nothing unique to C++
334 or libstdc++-v3 about this; it's just common behavior, given here
335 for background reasons.)
337 <p>Some of the object files which make up libstdc++.a are rather large.
338 If you create a statically-linked executable with
339 <code> -static</code>, those large object files are suddenly part
340 of your executable. Historically the best way around this was to
341 only place a very few functions (often only a single one) in each
342 source/object file; then extracting a single function is the same
343 as extracting a single .o file. For libstdc++-v3 this is only
344 possible to a certain extent; the object files in question contain
345 template classes and template functions, pre-instantiated, and
346 splitting those up causes severe maintenance headaches.
348 <p>It's not a bug, and it's not really a problem. Nevertheless, some
349 people don't like it, so here are two pseudo-solutions:
351 <p>If the only functions from libstdc++.a which you need are language
352 support functions (those listed in
353 <a href="../18_support/howto.html">clause 18</a> of the standard,
354 e.g., <code>new</code> and <code>delete</code>), then try linking
355 against <code>libsupc++.a</code> (usually specifying
356 <code>-lsupc++</code> when calling g++ for the final link step will
357 do it). This library contains only those support routines, one per
358 object file. But if you are using anything from the rest of the
359 library, such as IOStreams or vectors, then you'll still need
360 pieces from <code>libstdc++.a</code>.
362 <p>The second method is one we hope to incorporate into the library
363 build process. Some platforms can place each function and variable
364 into its own section in a .o file. The GNU linker can then perform
365 garbage collection on unused sections; this reduces the situation
366 to only copying needed functions into the executable, as before,
367 but all happens automatically.
369 <p>Unfortunately the garbage collection in GNU ld is buggy; sections
370 (corresponding to functions and variables) which <em>are</em> used
371 are mistakenly removed, leading to horrible crashes when your
372 executable starts up. For the time being, this feature is not used
373 when building the library.
377 <h1><a name="3_0">3.0 Platform-Specific Issues</a></h1>
378 <h2><a name="3_1">3.1 Can libstdc++-v3 be used with <my
379 favorite compiler>?</a></h2>
380 <p>Probably not. Yet.</p>
381 <p>Because GCC advances so rapidly, development and testing of
382 libstdc++ is being done almost entirely under that compiler.
383 If you are curious about whether other, lesser compilers
384 (*grin*) support libstdc++, you are more than welcome to try.
385 Configuring and building the library (see above) will still
386 require certain tools, however. Also keep in mind that
387 <em>building</em> libstdc++ does not imply that your compiler
388 will be able to <em>use</em> all of the features found in the
389 C++ Standard Library.
391 <p>Since the goal of ISO Standardization is for all C++
392 implementations to be able to share code, the final libstdc++
393 should, in theory, be useable under any ISO-compliant
394 compiler. It will still be targeted and optimized for
399 <h2><a name="3_2">3.2 [removed]</a></h2>
400 <p>This question has become moot and has been removed. The stub
401 is here to preserve numbering (and hence links/bookmarks).
405 <h2><a name="3_3">3.3 Building DEC OSF kills the assembler</a></h2>
406 <p>The <code>atomicity.h</code> header for the Alpha processor
407 currently uses pseudo-operators which the DEC assembler
408 doesn't understand (in particular, .subsection and .previous).
409 The simple solution is to install GNU <code>as</code> and arrange
410 for the GCC build to use it (or merge the sources and build
411 it during the bootstrap).
414 <a href="http://gcc.gnu.org/ml/libstdc++/2000-12/msg00279.html">knows
415 the DEC assembler well enough</a> to provide the equivalent of
416 these two pseudos would win praise and accolades from many.
420 <h2><a name="3_4">3.4 I can't use 'long long' on Solaris</a></h2>
421 <p>By default we try to support the C99 <code>long long</code> type.
422 This requires that certain functions from your C library be present.
424 <p>Up through release 3.0.2 the tests performed were too general, and
425 this feature was disabled when it did not need to be. The most
426 commonly reported platform affected was Solaris.
428 <p>This has been fixed for 3.0.3 and onwards.
432 <h1><a name="4_0">4.0 Known Bugs and Non-Bugs</a></h1>
433 <em>Note that this section can get rapdily outdated -- such is the
434 nature of an open-source project. For the latest information, join
435 the mailing list or look through recent archives. The RELEASE-
436 NOTES and BUGS files are generally kept up-to-date.</em>
438 <p>For 3.0.1, the most common "bug" is an apparently missing
439 "<code>../</code>" in include/Makefile, resulting in files
440 like gthr.h and gthr-single.h not being found.
443 <a href="http://gcc.gnu.org/install/configure.html">the configuration
444 instructions for GCC</a>,
445 specifically the part about configuring in a separate build directory,
446 and how strongly recommended it is. Building in the source directory
447 is fragile, is rarely tested, and tends to break, as in this case.
448 This was fixed for 3.0.2.
450 <p><strong>Please do not report these as bugs. We know about them.</strong>
451 Reporting this -- or any other problem that's already been fixed --
452 hinders the development of GCC, because we have to take time to
453 respond to your report. Thank you.
456 <h2><a name="4_1">4.1 What works already?</a></h2>
457 <p>This is a verbatim clip from the "Status" section
458 of the RELEASE-NOTES for the latest snapshot.
461 <!-- Yeah, I meant that "verbatim clip" thing literally... :-) -->
466 - preliminary doxygen documentation has been added. Running "make
467 doxygen" in the libstdc++-v3 build directory will generate HTML
468 documentation that can be used to cross-reference names and files in
470 - a dejagnu based testing framework has been added
471 - a new implementation of the concept checking code has been ported
472 from the boost libraries.
473 - support for -fno-exceptions has been added
474 - stdexcept was re-written
475 - using deprecated or antiquated headers now gives a warning
476 - the stdio interface to iostreams has been tweaked, and now works
477 with synchronized c/c++ io
478 - new libsupc++ routines implementing the IA-64 C++ ABI.
479 - HPUX configuration files
480 - support for AIX added
481 - a lot of bugs were fixed.
482 - preliminary named locales implemented
483 - portability improvements made to generation of <limits>
484 - speedups to improve configuration time.
485 - DJGPP support added.
486 - support for dlopening shared libstdc++
491 <h2><a name="4_2">4.2 Bugs in gcc/g++ (not libstdc++-v3)</a></h2>
492 <p>This is by no means meant to be complete nor exhaustive, but
493 mentions some problems that users may encounter when building
494 or using libstdc++. If you are experiencing one of these
495 problems, you can find more information on the libstdc++ and
496 the GCC mailing lists.
499 <li>As of 2.91, these bugs have all been fixed. We look forward
500 to new ones, well, not exactly...
504 <h2><a name="4_3">4.3 Bugs in the C++ language/lib specification</a></h2>
505 <p>Yes, unfortunately, there are some. In a
506 <a href="http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html">message
507 to the list</a>, Nathan Myers announced that he has started a list of
508 problems in the ISO C++ Standard itself, especially with
509 regard to the chapters that concern the library. The list
511 <a href="http://www.cantrip.org/draft-bugs.txt">posted on his
512 website</a>. Developers who are having problems interpreting
513 the Standard may wish to consult his notes.
515 <p>For those people who are not part of the ISO Library Group
516 (i.e., nearly all of us needing to read this page in the first
517 place :-), a public list of the library defects is occasionally
518 published <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/">here</a>.
519 Some of these have resulted in <a href="#5_2">code changes</a>.
523 <h2><a name="4_4">4.4 Things in libstdc++ that look like bugs</a></h2>
524 <p>There are things which are not bugs in the compiler (4.2) nor
525 the language specification (4.3), but aren't really bugs in
526 libstdc++, either. Really! Please do not report these as bugs.
529 <p><strong>-Weffc++</strong>
530 The biggest of these is the quadzillions of warnings about the
531 library headers emitted when <code>-Weffc++</code> is used. Making
532 libstdc++ "-Weffc++-clean" is not a goal of the project,
533 for a few reasons. Mainly, that option tries to enforce
534 object-oriented programming, while the Standard Library isn't
535 necessarily trying to be OO. There are multiple solutions
539 <a name="4_4_iostreamclear">
540 <p><strong>reopening a stream fails</strong>
541 Did I just say that -Weffc++ was our biggest false-bug report? I
542 lied. (It used to be.) Today it seems to be reports that after
543 executing a sequence like
545 #include <fstream>
547 std::fstream fs("a_file");
549 // . do things with fs...
552 fs.open("a_new_file");</pre>
553 all operations on the re-opened <code>fs</code> will fail, or at
554 least act very strangely. Yes, they often will, especially if
555 <code>fs</code> reached the EOF state on the previous file. The
556 reason is that the state flags are <strong>not</strong> cleared
557 on a successful call to open(). The standard unfortunately did
558 not specify behavior in this case, and to everybody's great sorrow,
559 the <a href="../ext/howto.html#5">proposed LWG resolution</a> (see
560 DR #22) is to leave the flags unchanged. You must insert a call
561 to <code>fs.clear()</code> between the calls to close() and open(),
562 and then everything will work like we all expect it to work.
565 <a name="4_4_rel_ops">
566 <p><strong>rel_ops</strong>
567 Another is the <code>rel_ops</code> namespace and the template
568 comparison operator functions contained therein. If they become
569 visible in the same namespace as other comparison functions
570 (e.g., '<code>using</code>' them and the <iterator> header),
571 then you will suddenly be faced with huge numbers of ambiguity
572 errors. This was discussed on the -v3 list; Nathan Myers
573 <a href="http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html">sums
577 <a name="4_4_interface"><h3>The g++-3 headers are
578 <em>not ours</em></h3>
579 <p>If you have found an extremely broken header file which is
580 causing problems for you, look carefully before submitting a
581 "high" priority bug report (which you probably shouldn't
582 do anyhow; see the last paragraph of the page describing
583 <a href="http://gcc.gnu.org/gnatswrite.html">the GCC bug database</a>).
585 <p>If the headers are in <CODE>${prefix}/include/g++-3</CODE>, then
586 you are using the old libstdc++-v2 library, which is nonstandard
587 and unmaintained. Do not report problems with -v2 to the -v3
590 <p>Currently our header files are installed in
591 <code>${prefix}/include/g++-v3</code> (see the 'v'?). This may
592 change with the next release of GCC, as it may be too confusing,
593 but <a href="http://gcc.gnu.org/ml/gcc/2000-10/msg00732.html">the
594 question has not yet been decided</a>.
598 <p><strong>glibc</strong>
599 If you're on a GNU/Linux system and have just upgraded to
600 glibc 2.2, but are still using gcc 2.95.2, then you should have
601 read the glibc FAQ, specifically 2.34:
603 2.34. When compiling C++ programs, I get a compilation error in streambuf.h.
605 {BH} You are using g++ 2.95.2? After upgrading to glibc 2.2, you need to
606 apply a patch to the include files in /usr/include/g++, because the fpos_t
607 type has changed in glibc 2.2. The patch is at
608 http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
610 Note that 2.95.x shipped with the
611 <a href="#4_4_interface">old v2 library</a> which is no longer
612 maintained. Also note that gcc 2.95.3 fixes this problem, but
613 requires a separate patch for libstdc++-v3.
616 <a name="4_4_checks">
617 <p><strong>concept checks</strong>
618 If you see compilation errors containing messages about
619 <code> <em>foo</em>Concept </code>and a<code> constraints </code>
620 member function, then most likely you have violated one of the
621 requirements for types used during instantiation of template
622 containers and functions. For example, EqualityComparableConcept
623 appears if your types must be comparable with == and you have not
624 provided this capability (a typo, or wrong visibility, or you
625 just plain forgot, etc).
627 <p>More information, including how to optionally enable/disable the
629 <a href="../19_diagnostics/howto.html#3">here</a>.
634 <h2><a name="4_5">4.5 Aw, that's easy to fix!</a></h2>
635 <p>If you have found a bug in the library and you think you have
636 a working fix, then send it in! The main GCC site has a page
637 on <a href="http://gcc.gnu.org/contribute.html">submitting
638 patches</a> that covers the procedure, but for libstdc++ you
639 should also send the patch to our mailing list in addition to
640 the GCC patches mailing list. The libstdc++
641 <a href="../17_intro/contribute.html">contributors' page</a>
642 also talks about how to submit patches.
644 <p>In addition to the description, the patch, and the ChangeLog
645 entry, it is a Good Thing if you can additionally create a small
646 test program to test for the presence of the bug that your
647 patch fixes. Bugs have a way of being reintroduced; if an old
648 bug creeps back in, it will be caught immediately by the
649 <a href="#2_4">testsuite</a> -- but only if such a test exists.
653 <h1><a name="5_0">5.0 Miscellaneous</a></h1>
654 <h2><a name="5_1">5.1 string::iterator is not char*;
655 vector<T>::iterator is not T*</a></h2>
656 <p>If you have code that depends on container<T> iterators
657 being implemented as pointer-to-T, your code is broken.
659 <p>While there are arguments for iterators to be implemented in
660 that manner, A) they aren't very good ones in the long term,
661 and B) they were never guaranteed by the Standard anyway. The
662 type-safety achieved by making iterators a real class rather
663 than a typedef for <code>T*</code> outweighs nearly all opposing
666 <p>Code which does assume that a vector iterator <code> i </code>
667 is a pointer can often be fixed by changing <code> i </code> in
668 certain expressions to <code> &*i </code>. Future revisions
669 of the Standard are expected to bless this usage for
670 vector<> (but not for basic_string<>).
674 <h2><a name="5_2">5.2 What's next after libstdc++-v3?</a></h2>
675 <p>Hopefully, not much. The goal of libstdc++-v3 is to produce
676 a fully-compliant, fully-portable Standard Library. After that,
677 we're mostly done: there won't <em>be</em> any more compliance
681 <li><p>The ISO Committee will meet periodically to review Defect Reports
682 in the C++ Standard. Undoubtedly some of these will result in
683 changes to the Standard, which will be reflected in patches to
684 libstdc++. Some of that is already happening, see 4.2. Some of
685 those changes are being predicted by the library maintainers, and
686 we add code to the library based on what the current proposed
687 resolution specifies. Those additions are listed in
688 <a href="../ext/howto.html#5">the extensions page</a>.
690 <li><p>Performance tuning. Lots of performance tuning. This too is
691 already underway for post-3.0 releases, starting with memory
692 expansion in container classes and buffer usage in synchronized
695 <li><p>An ABI for libstdc++ will eventually be developed, so that
696 multiple binary-incompatible copies of the library can be replaced
697 with a single backwards-compatible library, like libgcc_s.so is.
699 <li><p>The current libstdc++ contains extensions to the Library which
700 must be explicitly requested by client code (for example, the
701 hash tables from SGI). Other extensions may be added to
702 libstdc++-v3 if they seem to be "standard" enough.
703 (For example, the "long long" type from C99.)
704 Bugfixes and rewrites (to improve or fix thread safety, for
705 instance) will of course be a continuing task.
708 <p><a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html">This
709 question</a> about the next libstdc++ prompted some brief but
711 <a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation</a>.
715 <h2><a name="5_3">5.3 What about the STL from SGI?</a></h2>
716 <p>The <a href="http://www.sgi.com/Technology/STL/">STL from SGI</a>,
717 version 3.3, was the most recent merge of the STL codebase. The
718 code in libstdc++ contains many fixes and changes, and it is
719 very likely that the SGI code is no longer under active
720 development. We expect that no future merges will take place.
722 <p>In particular, <code>string</code> is not from SGI and makes no
723 use of their "rope" class (which is included as an
724 optional extension), nor is <code>valarray</code> and some others.
725 Classes like <code>vector<></code> are, however.
727 <p>The FAQ for SGI's STL (one jump off of their main page) is
732 <h2><a name="5_4">5.4 Extensions and Backward Compatibility</a></h2>
733 <p>Although you can specify <code>-I</code> options to make the
734 preprocessor search the g++-v3/ext and /backward directories,
735 it is better to refer to files there by their path, as in:
736 <!-- Careful, the leading spaces in PRE show up directly. -->
739 #include <ext/hash_map>
741 <p>Extensions to the library have
742 <a href="../ext/howto.html">their own page</a>.
746 <h2><a name="5_5">5.5 [removed]</a></h2>
747 <p>This question has become moot and has been removed. The stub
748 is here to preserve numbering (and hence links/bookmarks).
752 <h2><a name="5_6">5.6 Is libstdc++-v3 thread-safe?</a></h2>
753 <p>When the system's libc is itself thread-safe, a non-generic
754 implementation of atomicity.h exists for the architecture, and gcc
755 itself reports a thread model other than single; libstdc++-v3
756 strives to be thread-safe. The user-code must guard against
757 concurrent method calls which may access any particular library
758 object's state. Typically, the application programmer may infer
759 what object locks must be held based on the objects referenced in
760 a method call. Without getting into great detail, here is an
761 example which requires user-level locks:
763 library_class_a shared_object_a;
766 library_class_b *object_b = new library_class_b;
767 shared_object_a.add_b (object_b); // must hold lock for shared_object_a
768 shared_object_a.mutate (); // must hold lock for shared_object_a
771 // Multiple copies of thread_main() are started in independent threads.</pre>
773 <p>Under the assumption that object_a and object_b are never exposed to
774 another thread, here is an example that should not require any
778 library_class_a object_a;
779 library_class_b *object_b = new library_class_b;
780 object_a.add_b (object_b);
784 <p>All library objects are safe to use in a multithreaded program as
785 long as each thread carefully locks out access by any other thread
786 while it uses any object visible to another thread. In general,
787 this requirement includes both read and write access to objects;
788 unless otherwise documented as safe, do not assume that two
789 threads may access a shared standard library object at the
792 <p>See chapters <a href="../17_intro/howto.html#3">17</a> (library
793 introduction), <a href="../23_containers/howto.html#3">23</a>
794 (containers), and <a href="../27_io/howto.html#9">27</a> (I/O) for
799 <h2><a name="5_7">5.7 How do I get a copy of the ISO C++ Standard?</a></h2>
800 <p>Copies of the full ISO 14882 standard are available on line via the
801 ISO mirror site for committee members. Non-members, or those who
802 have not paid for the privilege of sitting on the committee and
803 sustained their two-meeting commitment for voting rights, may get a
804 copy of the standard from their respective national standards
805 organization. In the USA, this national standards organization is
806 ANSI and their website is right <a href="http://www.ansi.org">here</a>.
807 (And if you've already registered with them, clicking this link will
808 take you to directly to the place where you can
809 <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998">buy
810 the standard on-line</a>.
812 <p>Who is your country's member body? Visit the
813 <a href="http://www.iso.ch/">ISO homepage</a> and find out!
817 <h2><a name="5_8">5.8 What's an ABI and why is it so messy?</a></h2>
818 <p>"ABI" stands for "Application Binary Interface."
819 Conventionally, it refers to a great mass of details about how
820 arguments are arranged on the call stack and/or in registers, and
821 how various types are arranged and padded in structs. A single CPU
822 design may suffer multiple ABIs designed by different development
823 tool vendors who made different choices, or even by the same vendor
824 for different target applications or compiler versions. In ideal
825 circumstances the CPU designer presents one ABI and all the OSes and
826 compilers use it. In practice every ABI omits details that compiler
827 implementers (consciously or accidentally) must choose for themselves.
829 <p>That ABI definition suffices for compilers to generate code so a
830 program can interact safely with an OS and its lowest-level libraries.
831 Users usually want an ABI to encompass more detail, allowing libraries
832 built with different compilers (or different releases of the same
833 compiler!) to be linked together. For C++, this includes many more
834 details than for C, and CPU designers (for good reasons elaborated
835 below) have not stepped up to publish C++ ABIs. The details include
836 virtual function implementation, struct inheritance layout, name
837 mangling, and exception handling. Such an ABI has been defined for
838 GNU C++, and is immediately useful for embedded work relying only on
839 a "free-standing implementation" that doesn't include (much
840 of) the standard library. It is a good basis for the work to come.
842 <p>A useful C++ ABI must also incorporate many details of the standard
843 library implementation. For a C ABI, the layouts of a few structs
844 (such as FILE, stat, jmpbuf, and the like) and a few macros suffice.
845 For C++, the details include the complete set of names of functions
846 and types used, the offsets of class members and virtual functions,
847 and the actual definitions of all inlines. C++ exposes many more
848 library details to the caller than C does. It makes defining
849 a complete ABI a much bigger undertaking, and requires not just
850 documenting library implementation details, but carefully designing
851 those details so that future bug fixes and optimizations don't
852 force breaking the ABI.
854 <p>There are ways to help isolate library implementation details from the
855 ABI, but they trade off against speed. Library details used in
856 inner loops (e.g., getchar) must be exposed and frozen for all
857 time, but many others may reasonably be kept hidden from user code,
858 so they may later be changed. Deciding which, and implementing
859 the decisions, must happen before you can reasonably document a
860 candidate C++ ABI that encompasses the standard library.
863 <!-- ####################################################### -->
866 <p class="fineprint"><em>
867 See <a href="../17_intro/license.html">license.html</a> for copying conditions.
868 Comments and suggestions are welcome, and may be sent to
869 <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.