OSDN Git Service

e7da17e30831ce273fbd1b0820adaf1767d0883c
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / docs / html / faq / index.html
1 <html>
2 <head>
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">
8 <!-- 
9   ** Locations of "the most recent snapshot is the Nth" text are 
10   ** answers 1_1, 1_4, 4_1, 5_6.
11 -->
12 </head>
13 <body>
14
15 <h1 class="centered">libstdc++ Frequently Asked Questions</h1>
16
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>
20
21 <p>To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</a>.
22
23 <!-- ####################################################### -->
24 <hr>
25 <h1>Questions</h1>
26 <ol>
27    <li><a href="#1_0">General Information</a>
28    <!-- I suspect these will mostly be links to/into existing documents. -->
29    <ol>
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>
39    </ol>
40
41    <li><a href="#2_0">Installation</a>
42       <ol>
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 
46                             mentioning?</a>
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>
49       </ol>
50
51    <li><a href="#3_0">Platform-Specific Issues</a>
52       <ol>
53          <li><a href="#3_1">Can libstdc++-v3 be used with &lt;my
54                             favorite compiler&gt;?</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>
58       </ol>
59
60    <li><a href="#4_0">Known Bugs and Non-Bugs</a>
61       <ol>
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>
66            <ul>
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">&quot;ambiguous overloads&quot;
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>
76            </ul>
77          <li><a href="#4_5">Aw, that's easy to fix!</a>
78       </ol>
79
80    <li><a href="#5_0">Miscellaneous</a>
81       <ol>
82          <li><a href="#5_1">string::iterator is not char*;
83                             vector&lt;T&gt;::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>
91       </ol>
92
93 </ol>
94
95 <hr>
96
97 <!-- ####################################################### -->
98
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). 
112       </p> 
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>. 
115       </p> 
116
117 <hr>
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          &quot;incomplet and incorrekt,&quot; and many suffer from
124          limitations of the compilers that use them.
125       </p> 
126       <p>The GNU C/C++/FORTRAN/&lt;pick-a-language&gt; 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++.
135       </p>
136       <p>That means that all of the Standard classes and functions
137          (such as <code>string</code>, <code>vector&lt;&gt;</code>, iostreams,
138          and algorithms) will be freely available and fully compliant.
139          Programmers will no longer need to &quot;roll their own&quot;
140          nor be worried about platform-specific incompatabilities.
141       </p>
142
143 <hr>
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.
149       </p>
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!
155       </p>
156
157 <hr>
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.
162       </p>
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.
166       </p>
167       <p>The subset commonly known as the Standard Template Library
168          (chapters 23 through 25, mostly) is adapted from the final release
169          of the SGI STL.
170       </p> 
171
172 <hr>
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>
180       </p>
181
182 <hr>
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!
192       </p> 
193
194 <hr>
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.
199       </p>
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&lt;T&gt;</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.)
205       </p>
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 &quot;obvious&quot; classes
211          didn't get included.
212       </p>
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 &quot;useful stuff&quot;
219          from libg++ might be extracted into an updated utilities library,
220          but nobody has stated such a project yet.
221       </p>
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 &quot;useful
226          stuff&quot; classes will probably migrate there.)
227       </p>
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.
231       </p>
232
233 <hr>
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>.
242       </p>
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>.
247       </p>
248
249 <hr>
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.
253       </p>
254
255 <hr>
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:
260       </p>
261          <ul>
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.
269          </ul>
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.
275       </p>
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          &quot;.../docs/17_intro/&quot; directory of the distribution.
282       </p> 
283
284 <hr>
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).
288       </p>
289
290 <hr>
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 
298          well as a
299          <a href="http://www.cvshome.org/">link to the makers of CVS</a>. 
300       </p>
301       <p>The &quot;anonymous client checkout&quot; feature of CVS is
302          similar to anonymous FTP in that it allows anyone to retrieve
303          the latest libstdc++ sources.
304       </p>
305       <p>After the first of April, American users will have a
306          &quot;/pharmacy&quot; command-line option...
307          <!-- wonder how long that'll live -->
308       </p>
309
310 <hr>
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 (&quot;<code>make
314          install</code>&quot;) to run the testsuite.
315       </p>
316       <p>To run the testsuite on the library after building it, use
317          &quot;make check&quot; while in your build directory.  To run
318          the testsuite on the library after building and installing it,
319          use &quot;make check-install&quot; instead.
320       </p>
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!
324       </p>
325
326 <hr>
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 &quot;linker&quot;) 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.)
336       </p>
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.
347       </p>
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:
350       </p>
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>.
361       </p>
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.
368       </p>
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.
374       </p>
375
376 <hr>
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 &lt;my
379                          favorite compiler&gt;?</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.
390       </p>
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
395          GCC/g++, however.
396       </p> 
397
398 <hr>
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).
402       </p>
403
404 <hr>
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).
412       </p>
413       <p>Anyone who
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.
417       </p>
418
419 <hr>
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.
423       </p>
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.
427       </p>
428       <p>This has been fixed for 3.0.3 and onwards.
429       </p>
430
431 <hr>
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> 
437
438    <p>For 3.0.1, the most common &quot;bug&quot; is an apparently missing
439       &quot;<code>../</code>&quot; in include/Makefile, resulting in files
440       like gthr.h and gthr-single.h not being found.
441    </p>
442    <p>Please read
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.
449    </p>
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.
454    </p>
455
456    <h2><a name="4_1">4.1 What works already?</a></h2>
457       <p>This is a verbatim clip from the &quot;Status&quot; section
458           of the RELEASE-NOTES for the latest snapshot.
459       </p> 
460
461 <!-- Yeah, I meant that "verbatim clip" thing literally... :-)  -->
462
463 <pre>
464 New:
465 ---
466 - preliminary doxygen documentation has been added. Running &quot;make
467   doxygen&quot; in the libstdc++-v3 build directory will generate HTML
468   documentation that can be used to cross-reference names and files in
469   the library.
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 &lt;limits&gt;
484 - speedups to improve configuration time.
485 - DJGPP support added.
486 - support for dlopening shared libstdc++
487 </pre>
488
489
490 <hr>
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.
497       </p>
498       <ul>
499          <li>As of 2.91, these bugs have all been fixed.  We look forward
500              to new ones, well, not exactly...
501       </ul>
502
503 <hr>
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
510          itself is
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.
514       </p>
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>.
520       </p>
521
522 <hr>
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.
527       </p>
528       <a name="4_4_Weff">
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++ &quot;-Weffc++-clean&quot; 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
536            under discussion.
537         </p>
538       </a>
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
544            <pre>
545     #include &lt;fstream&gt;
546     ...
547     std::fstream  fs(&quot;a_file&quot;);
548     // .
549     // . do things with fs...
550     // .
551     fs.close();
552     fs.open(&quot;a_new_file&quot;);</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.
563         </p>
564       </a>
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 &lt;iterator&gt; 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
574            things up here</a>.
575         </p>
576       </a>
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            &quot;high&quot; 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>).
584         </p>
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
588            mailing list.
589         </p>
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>.
595         </p>
596       </a>
597       <a name="4_4_glibc">
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:
602    <pre>
603 2.34.   When compiling C++ programs, I get a compilation error in streambuf.h.
604
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
609    </pre>
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.
614         </p>
615       </a>
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).
626         </p>
627         <p>More information, including how to optionally enable/disable the
628            checks, is available
629            <a href="../19_diagnostics/howto.html#3">here</a>.
630         </p>
631       </a>
632
633 <hr>
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.
643       </p>
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.
650       </p>
651
652 <hr>
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&lt;T&gt;::iterator is not T*</a></h2>
656       <p>If you have code that depends on container&lt;T&gt; iterators
657          being implemented as pointer-to-T, your code is broken.
658       </p>
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
664          arguments.
665       </p>
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> &amp;*i </code>.  Future revisions
669          of the Standard are expected to bless this usage for
670          vector&lt;&gt; (but not for basic_string&lt;&gt;).
671       </p>
672
673 <hr>
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
678          work to do.  However:
679       </p>
680       <ol>
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>.
689       </p>
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
693          stream objects.
694       </p>
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.
698       </p>
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 &quot;standard&quot; enough.
703          (For example, the &quot;long long&quot; type from C99.)
704          Bugfixes and rewrites (to improve or fix thread safety, for
705          instance) will of course be a continuing task.
706       </p>
707       </ol>
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
710          interesting
711          <a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation</a>.
712       </p>
713
714 <hr>
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.
721       </p>
722       <p>In particular, <code>string</code> is not from SGI and makes no
723          use of their &quot;rope&quot; class (which is included as an
724          optional extension), nor is <code>valarray</code> and some others.
725          Classes like <code>vector&lt;&gt;</code> are, however.
726       </p>
727       <p>The FAQ for SGI's STL (one jump off of their main page) is
728          recommended reading.
729       </p>
730
731 <hr>
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. -->
737       </p>
738          <pre>
739        #include &lt;ext/hash_map&gt;
740          </pre>
741       <p>Extensions to the library have
742          <a href="../ext/howto.html">their own page</a>.
743       </p>
744
745 <hr>
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).
749       </p>
750
751 <hr>
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:
762          <pre>
763      library_class_a shared_object_a;
764
765      thread_main () {
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
769      }
770
771      // Multiple copies of thread_main() are started in independent threads.</pre>
772       </p>
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
775          user-level locks:
776          <pre>
777      thread_main () {
778        library_class_a object_a;
779        library_class_b *object_b = new library_class_b;
780        object_a.add_b (object_b);
781        object_a.mutate ();
782      } </pre>
783       </p>
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
790          same time.
791       </p>
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
795          more information.
796       </p>
797
798 <hr>
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>.
811       </p>
812       <p>Who is your country's member body?  Visit the
813          <a href="http://www.iso.ch/">ISO homepage</a> and find out!
814       </p>
815
816 <hr>
817    <h2><a name="5_8">5.8 What's an ABI and why is it so messy?</a></h2>
818       <p>&quot;ABI&quot; stands for &quot;Application Binary Interface.&quot;
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.
828       </p>
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 &quot;free-standing implementation&quot; that doesn't include (much
840          of) the standard library.  It is a good basis for the work to come.
841       </p>
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.
853       </p>
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.
861       </p>
862
863 <!-- ####################################################### -->
864
865 <hr>
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>.
870 </em></p>
871
872
873 </body>
874 </html>
875