OSDN Git Service

2002-10-07 Jonathan Wakely <jw@kayari.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / docs / html / faq / index.html
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html
3           PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <head>
7    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8    <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++, libg++, STL" />
9    <meta name="DESCRIPTION" content="FAQ for the GNU libstdc++ effort." />
10    <title>libstdc++-v3 FAQ</title>
11 <link rel="StyleSheet" href="../lib3styles.css" />
12 <!-- 
13   ** Locations of "the most recent snapshot is the Nth" text are 
14   ** answers 1_1, 1_4, 4_1.
15 -->
16 </head>
17 <body>
18
19 <h1 class="centered">libstdc++ Frequently Asked Questions</h1>
20
21 <p>The latest version of this document is always available at
22    <a href="http://gcc.gnu.org/onlinedocs/libstdc++/faq/">
23    http://gcc.gnu.org/onlinedocs/libstdc++/faq/</a>.  The main documentation
24    page is at
25    <a href="http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html">
26    http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html</a>.
27 </p>
28
29 <p>To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</a>.
30 </p>
31
32 <!-- ####################################################### -->
33 <hr />
34 <h1>Questions</h1>
35 <ol>
36    <li><a href="#1_0">General Information</a>
37    <!-- I suspect these will mostly be links to/into existing documents. -->
38    <ol>
39       <li><a href="#1_1">What is libstdc++-v3?</a> </li>
40       <li><a href="#1_2">Why should I use libstdc++?</a> </li>
41       <li><a href="#1_3">Who's in charge of it?</a> </li>
42       <li><a href="#1_4">How do I get libstdc++?</a> </li>
43       <li><a href="#1_5">When is libstdc++ going to be finished?</a> </li>
44       <li><a href="#1_6">How do I contribute to the effort?</a> </li>
45       <li><a href="#1_7">What happened to libg++?  I need that!</a> </li>
46       <li><a href="#1_8">What if I have more questions?</a> </li>
47       <li><a href="#1_9">What are the license terms for libstdc++-v3?</a> </li>
48    </ol>
49    </li>
50
51    <li><a href="#2_0">Installation</a>
52       <ol>
53          <li><a href="#2_1">How do I install libstdc++-v3?</a> </li>
54          <li><a href="#2_2">[removed]</a> </li>
55          <li><a href="#2_3">What is this CVS thing that you keep 
56                             mentioning?</a> </li>
57          <li><a href="#2_4">How do I know if it works?</a> </li>
58          <li><a href="#2_5">This library is HUGE!  And what's libsupc++?</a> </li>
59       </ol>
60    </li>
61
62    <li><a href="#3_0">Platform-Specific Issues</a>
63       <ol>
64          <li><a href="#3_1">Can libstdc++-v3 be used with &lt;my
65                             favorite compiler&gt;?</a> </li>
66          <li><a href="#3_2">[removed]</a> </li>
67          <li><a href="#3_3">[removed]</a> </li>
68          <li><a href="#3_4">I can't use 'long long' on Solaris</a> </li>
69          <li><a href="#3_5"><code>_XOPEN_SOURCE</code> /
70                             <code>_GNU_SOURCE</code> / etc is always defined</a>
71          </li>
72          <li><a href="#3_6">OS X ctype.h is broken!  How can I hack it?</a> </li>
73       </ol>
74    </li>
75
76    <li><a href="#4_0">Known Bugs and Non-Bugs</a>
77       <ol>
78          <li><a href="#4_1">What works already?</a> </li>
79          <li><a href="#4_2">Bugs in gcc/g++ (not libstdc++-v3)</a> </li>
80          <li><a href="#4_3">Bugs in the C++ language/lib specification</a> </li>
81          <li><a href="#4_4">Things in libstdc++ that only look like bugs</a><ul>
82            <li><a href="#4_4_iostreamclear">reopening a stream fails</a> </li>
83            <li><a href="#4_4_Weff">-Weffc++ complains too much</a> </li>
84            <li><a href="#4_4_rel_ops">&quot;ambiguous overloads&quot;
85                                after including an old-style header</a> </li>
86            <li><a href="#4_4_interface">The g++-3 headers are
87                                <strong>not ours</strong></a> </li>
88            <li><a href="#4_4_glibc">compilation errors from streambuf.h</a> </li>
89            <li><a href="#4_4_checks">errors about <em>*Concept</em> and
90                                <em>constraints</em> in the STL...</a> </li>
91            <li><a href="#4_4_dlsym">program crashes when using library code
92                                in a dynamically-loaded library</a> </li>
93          </ul>
94          </li>
95          <li><a href="#4_5">Aw, that's easy to fix!</a> </li>
96       </ol>
97    </li>
98
99    <li><a href="#5_0">Miscellaneous</a>
100       <ol>
101          <li><a href="#5_1">string::iterator is not char*;
102                             vector&lt;T&gt;::iterator is not T*</a> </li>
103          <li><a href="#5_2">What's next after libstdc++-v3?</a> </li>
104          <li><a href="#5_3">What about the STL from SGI?</a> </li>
105          <li><a href="#5_4">Extensions and Backward Compatibility</a> </li>
106          <li><a href="#5_5">[removed]</a> </li>
107          <li><a href="#5_6">Is libstdc++-v3 thread-safe?</a> </li>
108          <li><a href="#5_7">How do I get a copy of the ISO C++ Standard?</a> </li>
109          <li><a href="#5_8">What's an ABI and why is it so messy?</a> </li>
110       </ol>
111    </li>
112
113 </ol>
114
115 <hr />
116
117 <!-- ####################################################### -->
118
119 <h1><a name="1_0">1.0 General Information</a></h1>
120 <!-- I suspect these will mostly be links to/into existing documents. -->
121    <h2><a name="1_1">1.1 What is libstdc++-v3?</a></h2>
122       <p>The GNU Standard C++ Library v3 is an
123          ongoing project to implement the ISO 14882 Standard C++ library 
124          as described in chapters 17 through 27 and annex D.  As the 
125          library reaches stable plateaus, it is captured in a snapshot
126          and released.  The current release is
127          <a href="http://gcc.gnu.org/libstdc++/index.html#download">the
128          fourteenth snapshot</a>.  For those who want to see exactly how
129          far the project has come, or just want the latest
130          bleeding-edge code, the up-to-date source is available over
131          anonymous CVS, and can even be browsed over the Web (see below). 
132       </p>
133       <p>The older libstdc++-v2 project is no longer maintained; the code
134          has been completely replaced and rewritten.
135          <a href="#4_4_interface">If you are using V2</a>, then you need to
136          report bugs to your system vendor, not to the V3 list.
137       </p>
138       <p>A more formal description of the V3 goals can be found in the
139          official <a href="../17_intro/DESIGN">design document</a>. 
140       </p>
141
142 <hr />
143    <h2><a name="1_2">1.2 Why should I use libstdc++?</a></h2>
144       <p>The completion of the ISO C++ standardization gave the
145          C++ community a powerful set of reuseable tools in the form
146          of the C++ Standard Library.  However, all existing C++
147          implementations are (as the Draft Standard used to say)
148          &quot;incomplet and incorrekt,&quot; and many suffer from
149          limitations of the compilers that use them.
150       </p> 
151       <p>The GNU C/C++/FORTRAN/&lt;pick-a-language&gt; compiler
152          (<code>gcc</code>, <code>g++</code>, etc) is widely considered to be
153          one of the leading compilers in the world.  Its development
154          has recently been taken over by the 
155          <a href="http://gcc.gnu.org/">GCC team</a>.  All of
156          the rapid development and near-legendary
157          <a href="http://gcc.gnu.org/gcc-3.0/buildstat.html">portability</a>
158          that are the hallmarks of an open-source project are being
159          applied to libstdc++.
160       </p>
161       <p>That means that all of the Standard classes and functions
162          (such as <code>string</code>, <code>vector&lt;&gt;</code>, iostreams,
163          and algorithms) will be freely available and fully compliant.
164          Programmers will no longer need to &quot;roll their own&quot;
165          nor be worried about platform-specific incompatibilities.
166       </p>
167
168 <hr />
169    <h2><a name="1_3">1.3 Who's in charge of it?</a></h2>
170       <p>The libstdc++ project is contributed to by several developers
171          all over the world, in the same way as GCC or Linux.
172          Benjamin Kosnik, Gabriel Dos Reis, Phil Edwards, Ulrich Drepper, 
173          Loren James Rittle, and Paolo Carlini are the lead maintainers of 
174          the CVS archive.
175       </p>
176       <p>Development and discussion is held on the libstdc++ mailing
177          list.  Subscribing to the list, or searching the list
178          archives, is open to everyone.  You can read instructions for
179          doing so on the <a href="http://gcc.gnu.org/libstdc++/">homepage</a>.
180          If you have questions, ideas, code, or are just curious, sign up!
181       </p>
182
183 <hr />
184    <h2><a name="1_4">1.4 How do I get libstdc++?</a></h2>
185       <p>The fourteenth (and latest) snapshot of libstdc++-v3 is
186          <a href="http://gcc.gnu.org/libstdc++/index.html#download">available
187          via ftp</a>.
188       </p>
189       <p>The <a href="http://gcc.gnu.org/libstdc++/">homepage</a>
190          has instructions for retrieving the latest CVS sources, and for
191          browsing the CVS sources over the web.
192       </p>
193       <p>The subset commonly known as the Standard Template Library
194          (chapters 23 through 25, mostly) is adapted from the final release
195          of the SGI STL.
196       </p> 
197
198 <hr />
199    <h2><a name="1_5">1.5 When is libstdc++ going to be finished?</a></h2>
200 <!--      <p>Nathan Myers gave the best of all possible answers in <a 
201          href="http://www.deja.com/getdoc.xp?AN=469581698&fmt=text">a 
202          Usenet article</a>.</p>
203 which is no longer available, thanks deja...-->
204       <p>Nathan Myers gave the best of all possible answers, responding to a
205          Usenet article asking this question:  <em>Sooner, if you help.</em>
206       </p>
207
208 <hr />
209    <h2><a name="1_6">1.6 How do I contribute to the effort?</a></h2>
210       <p>Here is <a href="../17_intro/contribute.html">a
211          page devoted to this topic</a>.  Subscribing to the mailing
212          list (see above, or the homepage) is a very good idea if you
213          have something to contribute, or if you have spare time and
214          want to help.  Contributions don't have to be in the form of
215          source code; anybody who is willing to help write
216          documentation, for example, or has found a bug in code that
217          we all thought was working, is more than welcome!
218       </p> 
219
220 <hr />
221    <h2><a name="1_7">1.7 What happened to libg++?  I need that!</a></h2>
222       <p>The most recent libg++ README states that libg++ is no longer
223          being actively maintained.  It should not be used for new
224          projects, and is only being kicked along to support older code.
225       </p>
226       <p>The libg++ was designed and created when there was no Standard
227          to provide guidance.  Classes like linked lists are now provided
228          for by <code>list&lt;T&gt;</code> and do not need to be created by
229          <code>genclass</code>.  (For that matter, templates exist now and
230          are well-supported, whereas genclass (mostly) predates them.)
231       </p>
232       <p>There are other classes in libg++ that are not specified in the
233          ISO Standard (e.g., statistical analysis).  While there are a
234          lot of really useful things that are used by a lot of people
235          (e.g., statistics :-), the Standards Committee couldn't include
236          everything, and so a lot of those &quot;obvious&quot; classes
237          didn't get included.
238       </p>
239       <p>Since libstdc++ is an implementation of the Standard Library, we
240          have no plans at this time to include non-Standard utilities
241          in the implementation, however handy they are.  (The extensions
242          provided in the SGI STL aren't maintained by us and don't get
243          a lot of our attention, because they don't require a lot of our
244          time.)  It is entirely plausable that the &quot;useful stuff&quot;
245          from libg++ might be extracted into an updated utilities library,
246          but nobody has stated such a project yet.
247       </p>
248       <!-- The advertisement, so to speak, might have to go.  Hmmmmm.  -->
249       <p>(The <a href="http://www.boost.org/">Boost</a> site houses free
250          C++ libraries that do varying things, and happened to be started
251          by members of the Standards Committee.  Certain &quot;useful
252          stuff&quot; classes will probably migrate there.)
253       </p>
254       <p>For the bold and/or desperate, the
255          <a href="http://gcc.gnu.org/fom_serv/cache/33.html">GCC FAQ</a>
256          describes where to find the last libg++ source.
257       </p>
258
259 <hr />
260    <h2><a name="1_8">1.8 What if I have more questions?</a></h2>
261       <p>If you have read the README and RELEASE-NOTES files, and your
262          question remains unanswered, then just ask the mailing list.
263          At present, you do not need to be subscribed to the list to
264          send a message to it.  More information is available on the
265          homepage (including how to browse the list archives); to send
266          to the list, use <a href="mailto:libstdc++@gcc.gnu.org">
267          <code>libstdc++@gcc.gnu.org</code></a>.
268       </p>
269       <p>If you have a question that you think should be included here,
270          or if you have a question <em>about</em> a question/answer here,
271          contact <a href="mailto:pme@gcc.gnu.org">Phil Edwards</a>
272          or <a href="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</a>.
273       </p>
274
275 <hr />
276    <h2><a name="1_9">1.9 What are the license terms for libstdc++-v3?</a></h2>
277       <p>See <a href="../17_intro/license.html">our license description</a>
278          for these and related questions.
279       </p>
280
281 <hr />
282 <h1><a name="2_0">2.0 Installation</a></h1>
283    <h2><a name="2_1">2.1 How do I install libstdc++-v3?</a></h2>
284       <p>Complete instructions are not given here (this is a FAQ, not
285          an installation document), but the tools required are few:
286       </p>
287          <ul>
288             <li> A 3.x release of GCC.  Note that building GCC is much
289                  easier and more automated than building the GCC 2.[78]
290                  series was.  If you are using GCC 2.95, you can still
291                  build earlier snapshots of libstdc++.
292             </li>
293             <li> GNU Make is recommended, but should not be required.
294             </li>
295             <li> The GNU Autotools are needed if you are messing with
296                  the configury or makefiles.
297             </li>
298          </ul>
299       <p>The file <a href="../documentation.html">documentation.html</a>
300          provides a good overview of the steps necessary to build, install,
301          and use the library.  Instructions for configuring the library
302          with new flags such as --enable-threads are there also, as well as
303          patches and instructions for working with GCC 2.95.
304       </p>
305       <p>The top-level install.html and
306          <a href="../17_intro/RELEASE-NOTES">RELEASE-NOTES</a> files contain
307          the exact build and installation instructions.  You may wish to
308          browse those files over CVSweb ahead of time to get a feel for
309          what's required.  RELEASE-NOTES is located in the
310          &quot;.../docs/17_intro/&quot; directory of the distribution.
311       </p> 
312
313 <hr />
314    <h2><a name="2_2">2.2 [removed]</a></h2>
315       <p>This question has become moot and has been removed.  The stub
316          is here to preserve numbering (and hence links/bookmarks).
317       </p>
318
319 <hr />
320    <h2><a name="2_3">2.3 What is this CVS thing that you
321                          keep mentioning?</a></h2>
322       <p>The <em>Concurrent Versions System</em> is one of several revision
323          control packages.  It was selected for GNU projects because it's
324          free (speech), free (beer), and very high quality.  The <a
325          href="http://www.gnu.org/software/cvs/cvs.html">CVS entry in
326          the GNU software catalogue</a> has a better description as 
327          well as a
328          <a href="http://www.cvshome.org/">link to the makers of CVS</a>. 
329       </p>
330       <p>The &quot;anonymous client checkout&quot; feature of CVS is
331          similar to anonymous FTP in that it allows anyone to retrieve
332          the latest libstdc++ sources.
333       </p>
334       <p>After the first of April, American users will have a
335          &quot;/pharmacy&quot; command-line option...
336          <!-- wonder how long that'll live -->
337       </p>
338
339 <hr />
340    <h2><a name="2_4">2.4 How do I know if it works?</a></h2>
341       <p>libstdc++-v3 comes with its own testsuite.  You do not need
342          to actually install the library (&quot;<code>make
343          install</code>&quot;) to run the testsuite.
344       </p>
345       <p>To run the testsuite on the library after building it, use
346          &quot;make check&quot; while in your build directory.  To run
347          the testsuite on the library after building and installing it,
348          use &quot;make check-install&quot; instead.
349       </p>
350       <p>If you find bugs in the testsuite programs themselves, or if you
351          think of a new test program that should be added to the suite,
352          <strong>please</strong> write up your idea and send it to the list!
353       </p>
354
355 <hr />
356    <h2><a name="2_5">2.4 This library is HUGE!  And what's libsupc++?</a></h2>
357       <p>Usually the size of libraries on disk isn't noticeable.  When a
358          link editor (or simply &quot;linker&quot;) pulls things from a
359          static archive library, only the necessary object files are copied
360          into your executable, not the entire library.  Unfortunately, even
361          if you only need a single function or variable from an object file,
362          the entire object file is extracted.  (There's nothing unique to C++
363          or libstdc++-v3 about this; it's just common behavior, given here
364          for background reasons.)
365       </p>
366       <p>Some of the object files which make up libstdc++.a are rather large.
367          If you create a statically-linked executable with
368          <code> -static</code>, those large object files are suddenly part
369          of your executable.  Historically the best way around this was to
370          only place a very few functions (often only a single one) in each
371          source/object file; then extracting a single function is the same
372          as extracting a single .o file.  For libstdc++-v3 this is only
373          possible to a certain extent; the object files in question contain
374          template classes and template functions, pre-instantiated, and
375          splitting those up causes severe maintenance headaches.
376       </p>
377       <p>It's not a bug, and it's not really a problem.  Nevertheless, some
378          people don't like it, so here are two pseudo-solutions:
379       </p>
380       <p>If the only functions from libstdc++.a which you need are language
381          support functions (those listed in
382          <a href="../18_support/howto.html">clause 18</a> of the standard,
383          e.g., <code>new</code> and <code>delete</code>), then try linking
384          against <code>libsupc++.a</code> (usually specifying
385          <code>-lsupc++</code> when calling g++ for the final link step will
386          do it).  This library contains only those support routines, one per
387          object file.  But if you are using anything from the rest of the
388          library, such as IOStreams or vectors, then you'll still need
389          pieces from <code>libstdc++.a</code>.
390       </p>
391       <p>The second method is one we hope to incorporate into the library
392          build process.  Some platforms can place each function and variable
393          into its own section in a .o file.  The GNU linker can then perform
394          garbage collection on unused sections; this reduces the situation
395          to only copying needed functions into the executable, as before,
396          but all happens automatically.
397       </p>
398       <p>Unfortunately the garbage collection in GNU ld is buggy; sections
399          (corresponding to functions and variables) which <em>are</em> used
400          are mistakenly removed, leading to horrible crashes when your
401          executable starts up.  For the time being, this feature is not used
402          when building the library.
403       </p>
404
405 <hr />
406 <h1><a name="3_0">3.0 Platform-Specific Issues</a></h1>
407    <h2><a name="3_1">3.1 Can libstdc++-v3 be used with &lt;my
408                          favorite compiler&gt;?</a></h2>
409       <p>Probably not.  Yet.</p>
410       <p>Because GCC advances so rapidly, development and testing of
411          libstdc++ is being done almost entirely under that compiler.
412          If you are curious about whether other, lesser compilers
413          (*grin*) support libstdc++, you are more than welcome to try.
414          Configuring and building the library (see above) will still
415          require certain tools, however.  Also keep in mind that
416          <em>building</em> libstdc++ does not imply that your compiler
417          will be able to <em>use</em> all of the features found in the
418          C++ Standard Library.
419       </p>
420       <p>Since the goal of ISO Standardization is for all C++
421          implementations to be able to share code, the final libstdc++
422          should, in theory, be usable under any ISO-compliant
423          compiler.  It will still be targeted and optimized for
424          GCC/g++, however.
425       </p> 
426
427 <hr />
428    <h2><a name="3_2">3.2 [removed]</a></h2>
429       <p>This question has become moot and has been removed.  The stub
430          is here to preserve numbering (and hence links/bookmarks).
431       </p>
432
433 <hr />
434    <h2><a name="3_3">3.3 [removed]</a></h2>
435       <p>This question has become moot and has been removed.  The stub
436          is here to preserve numbering (and hence links/bookmarks).
437       </p>
438
439 <hr />
440    <h2><a name="3_4">3.4 I can't use 'long long' on Solaris</a></h2>
441       <p>By default we try to support the C99 <code>long long</code> type.
442          This requires that certain functions from your C library be present.
443       </p>
444       <p>Up through release 3.0.2 the tests performed were too general, and
445          this feature was disabled when it did not need to be.  The most
446          commonly reported platform affected was Solaris.
447       </p>
448       <p>This has been fixed for 3.0.3 and onwards.
449       </p>
450
451 <hr />
452    <h2><a name="3_5">3.5 <code>_XOPEN_SOURCE</code> / <code>_GNU_SOURCE</code>
453                          / etc is always defined</a></h2>
454       <p>On Solaris, g++ (but not gcc) always defines the preprocessor
455          macro <code>_XOPEN_SOURCE</code>.  On GNU/Linux, the same happens
456          with <code>_GNU_SOURCE</code>.  (This is not an exhaustive list;
457          other macros and other platforms are also affected.)
458       </p>
459       <p>These macros are typically used in C library headers, guarding new
460          versions of functions from their older versions.  The C++ standard
461          library includes the C standard library, but it requires the C90
462          version, which for backwards-compatability reasons is often not the
463          default for many vendors.
464       </p>
465       <p>More to the point, the C++ standard requires behavior which is only
466          available on certain platforms after certain symbols are defined.
467          Usually the issue involves I/O-related typedefs.  In order to
468          ensure correctness, the compiler simply predefines those symbols.
469       </p>
470       <p>Note that it's not enough to #define them only when the library is
471          being built (during installation).  Since we don't have an 'export'
472          keyword, much of the library exists as headers, which means that
473          the symbols must also be defined as your programs are parsed and
474          compiled.
475       </p>
476       <p>To see which symbols are defined, look for CPLUSPLUS_CPP_SPEC in
477          the gcc config headers for your target (and try changing them to
478          see what happens when building complicated code).  You can also run
479          <code>&quot;g++ -E -dM - &lt; /dev/null&quot;</code> to display
480          a list of predefined macros for any particular installation.
481       </p>
482       <p>This has been discussed on the mailing lists
483          <a href="http://gcc.gnu.org/cgi-bin/htsearch?method=and&amp;format=builtin-long&amp;sort=score&amp;words=_XOPEN_SOURCE+Solaris">quite a bit</a>.
484       </p>
485       <p>This method is something of a wart.  We'd like to find a cleaner
486          solution, but nobody yet has contributed the time.
487       </p>
488
489 <hr />
490    <h2><a name="3_6">3.6 OS X ctype.h is broken!  How can I hack it?</a></h2>
491       <p>This is a long-standing bug in the OS X support.  Fortunately,
492          the patch is quite simple, and well-known.
493          <a href="http://gcc.gnu.org/ml/gcc/2002-03/msg00817.html"> Here's a
494          link to the solution.</a>
495       </p>
496
497 <hr />
498 <h1><a name="4_0">4.0 Known Bugs and Non-Bugs</a></h1>
499    <em>Note that this section can get rapdily outdated -- such is the
500    nature of an open-source project.  For the latest information, join
501    the mailing list or look through recent archives.   The RELEASE-
502    NOTES and BUGS files are generally kept up-to-date.</em> 
503
504    <p>For 3.0.1, the most common &quot;bug&quot; is an apparently missing
505       &quot;<code>../</code>&quot; in include/Makefile, resulting in files
506       like gthr.h and gthr-single.h not being found.  Please read
507       <a href="http://gcc.gnu.org/install/configure.html">the configuration
508       instructions for GCC</a>,
509       specifically the part about configuring in a separate build directory,
510       and how strongly recommended it is.  Building in the source directory
511       is fragile, is rarely tested, and tends to break, as in this case.
512       This was fixed for 3.0.2.
513    </p>
514
515    <p>For 3.1, the most common &quot;bug&quot; is a parse error when using
516       <code>&lt;fstream&gt;</code>, ending with a message,
517       &quot;<code>bits/basic_file.h:52: parse error before `{'
518       token</code>.&quot;  Please read
519       <a href="http://gcc.gnu.org/install/">the installation instructions for
520       GCC</a>, specifically the part about not installing newer versions on
521       top of older versions.  If you install 3.1 over a 3.0.x release, then
522       the wrong basic_file.h header will be found (its location changed
523       between releases).
524    </p>
525
526    <p><strong>Please do not report these as bugs.  We know about them.</strong>
527       Reporting this -- or any other problem that's already been fixed --
528       hinders the development of GCC, because we have to take time to
529       respond to your report.  Thank you.
530    </p>
531
532    <h2><a name="4_1">4.1 What works already?</a></h2>
533       <p>This is a verbatim clip from the &quot;Status&quot; section
534          of the RELEASE-NOTES for the latest snapshot.  For a list of
535          fixed bugs, see that file.
536       </p> 
537
538 <!-- Yeah, I meant that "verbatim clip" thing literally... :-)  -->
539
540 <pre>
541 New:
542 ---
543 (post 3.0.97)
544 - more doxygen documentation
545 - more named locale fixups
546 - stdio_filebuf that takes fd, FILE
547 - io performance tuning
548 - allocation tuning, valgrind fixups
549 - __cxa_demangle now supported
550 (3.0.97)
551 - more doxygen documentation.
552 - more named locale bug fixes
553 - support for symbol versioning when using GNU ld &gt;= 2.12
554 - wide-io
555 - tuning for executable size
556 (3.0.96)
557 - more doxygen documentation.
558 - extensions moved out of namespace std
559 - HPUX long long support
560 - more string optimizations
561 - support for NetBSD cross compiles
562 - concept_check merge from boost
563 - header simplification
564 - named locale bug shakeout
565 - thread testsuite
566 (3.0.95)
567 - add S390, m68k, x86-64 support.
568 - doxygen documentation has been extended, including man pages.
569 - verbose terminate handling has been added.
570 - some libsupc++ tweaks
571 - warnings for deprecated headers now active.
572 - dejagnu testsuite preliminary documentation.
573 - dejagnu testsuite default.
574 - dejagnu testsuite cross compiler, multilib safe.
575 - long long iostreams on by default, rework of ISO C99 support.
576 - iterator re-write and testsuites.
577 - container testsuites.
578 - allocator revamp and testsuites.
579 - more concept-checking work.
580 - basic_string optimization and MT fixes.
581 - new limits implementation.
582 - update -fno-exceptions code, verify it works.
583 - full named locale support fpr all facets, choice of gnu,
584   ieee_1003.1-200x (POSIX 2), or generic models. Full support depends
585   on target OS and underlying &quot;C&quot; library support.
586 </pre>
587
588
589 <hr />
590    <h2><a name="4_2">4.2 Bugs in gcc/g++ (not libstdc++-v3)</a></h2>
591       <p>This is by no means meant to be complete nor exhaustive, but
592          mentions some problems that users may encounter when building
593          or using libstdc++.  If you are experiencing one of these
594          problems, you can find more information on the libstdc++ and
595          the GCC mailing lists.
596       </p>
597       <p>Before reporting a bug, examine the
598          <a href="http://gcc.gnu.org/bugs.html">bugs database</a> with the
599          category set to &quot;libstdc++&quot;.  The BUGS file in the source
600          tree also tracks known serious problems.
601       </p>
602       <ul>
603          <li>Debugging is problematic, due to bugs in line-number generation
604              (mostly fixed in the compiler) and gdb lagging behind the
605              compiler (lack of personnel).  We recommend configuring the
606              compiler using <code>--with-dwarf2</code> if the DWARF2
607              debugging format is not already the default on your platform.
608              Also,
609 <a href="http://gcc.gnu.org/ml/libstdc++/2002-02/msg00034.html">changing your
610              GDB settings</a> can have a profound effect on your C++ debugging
611              experiences.  :-)</li>
612       </ul>
613
614 <hr />
615    <h2><a name="4_3">4.3 Bugs in the C++ language/lib specification</a></h2>
616       <p>Yes, unfortunately, there are some.  In a
617          <a href="http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html">message
618          to the list</a>, Nathan Myers announced that he has started a list of
619          problems in the ISO C++ Standard itself, especially with
620          regard to the chapters that concern the library.  The list
621          itself is
622          <a href="http://www.cantrip.org/draft-bugs.txt">posted on his
623          website</a>.  Developers who are having problems interpreting
624          the Standard may wish to consult his notes.
625       </p>
626       <p>For those people who are not part of the ISO Library Group
627          (i.e., nearly all of us needing to read this page in the first
628          place :-), a public list of the library defects is occasionally
629          published <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/">here</a>.
630          Some of these have resulted in <a href="#5_2">code changes</a>.
631       </p>
632
633 <hr />
634    <h2><a name="4_4">4.4 Things in libstdc++ that only look like bugs</a></h2>
635       <p>There are things which are not bugs in the compiler (4.2) nor
636          the language specification (4.3), but aren't really bugs in
637          libstdc++, either.  Really!  Please do not report these as bugs.
638       </p>
639       <p><a name="4_4_Weff"><strong>-Weffc++</strong></a>
640          The biggest of these is the quadzillions of warnings about the
641          library headers emitted when <code>-Weffc++</code> is used.  Making
642          libstdc++ &quot;-Weffc++-clean&quot; is not a goal of the project,
643          for a few reasons.  Mainly, that option tries to enforce
644          object-oriented programming, while the Standard Library isn't
645          necessarily trying to be OO.
646       </p>
647       <p><a name="4_4_iostreamclear"><strong>reopening a stream fails</strong>
648          </a> Did I just say that -Weffc++ was our biggest false-bug report?
649          I lied.  (It used to be.)  Today it seems to be reports that after
650          executing a sequence like
651       </p>
652       <pre>
653     #include &lt;fstream&gt;
654     ...
655     std::fstream  fs(&quot;a_file&quot;);
656     // .
657     // . do things with fs...
658     // .
659     fs.close();
660     fs.open(&quot;a_new_file&quot;);</pre>
661       <p>all operations on the re-opened <code>fs</code> will fail, or at
662          least act very strangely.  Yes, they often will, especially if
663          <code>fs</code> reached the EOF state on the previous file.  The
664          reason is that the state flags are <strong>not</strong> cleared
665          on a successful call to open().  The standard unfortunately did
666          not specify behavior in this case, and to everybody's great sorrow,
667          the <a href="../ext/howto.html#5">proposed LWG resolution</a> (see
668          DR #22) is to leave the flags unchanged.  You must insert a call
669          to <code>fs.clear()</code> between the calls to close() and open(),
670          and then everything will work like we all expect it to work.
671       </p>
672       <p><a name="4_4_rel_ops"><strong>rel_ops</strong></a>
673          Another is the <code>rel_ops</code> namespace and the template
674          comparison operator functions contained therein.  If they become
675          visible in the same namespace as other comparison functions
676          (e.g., '<code>using</code>' them and the &lt;iterator&gt; header),
677          then you will suddenly be faced with huge numbers of ambiguity
678          errors.  This was discussed on the -v3 list; Nathan Myers
679          <a href="http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html">sums
680          things up here</a>.  The collisions with vector/string iterator
681          types have been fixed for 3.1.  <!-- more links to email here -->
682       </p>
683       <h3><a name="4_4_interface">The g++-3 headers are <em>not ours</em></a></h3>
684       <p>If you have found an extremely broken header file which is
685          causing problems for you, look carefully before submitting a
686          &quot;high&quot; priority bug report (which you probably shouldn't
687          do anyhow; see the last paragraph of the page describing
688          <a href="http://gcc.gnu.org/gnatswrite.html">the GCC bug database</a>).
689       </p>
690       <p>If the headers are in <code>${prefix}/include/g++-3</code>, or if
691          the installed library's name looks like <code>libstdc++-2.10.a</code>
692          or <code>libstdc++-libc6-2.10.so</code>,
693          then you are using the old libstdc++-v2 library, which is nonstandard
694          and unmaintained.  Do not report problems with -v2 to the -v3
695          mailing list.
696       </p>
697       <p>Currently our header files are installed in
698          <code>${prefix}/include/g++-v3</code> (see the 'v'?).  This may
699          change with the next release of GCC, as it may be too confusing,
700          but <a href="http://gcc.gnu.org/ml/gcc/2000-10/msg00732.html">the
701          question has not yet been decided</a>.
702       </p>
703       <p><a name="4_4_glibc"><strong>glibc</strong></a>
704          If you're on a GNU/Linux system and have just upgraded to
705          glibc 2.2, but are still using gcc 2.95.2, then you should have
706          read the glibc FAQ, specifically 2.34:
707       </p>
708       <pre>
709 2.34.   When compiling C++ programs, I get a compilation error in streambuf.h.
710
711 {BH} You are using g++ 2.95.2? After upgrading to glibc 2.2, you need to
712 apply a patch to the include files in /usr/include/g++, because the fpos_t
713 type has changed in glibc 2.2.  The patch is at
714 http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
715    </pre>
716       <p>Note that 2.95.x shipped with the
717          <a href="#4_4_interface">old v2 library</a> which is no longer
718          maintained.  Also note that gcc 2.95.3 fixes this problem, but
719          requires a separate patch for libstdc++-v3.
720       </p>
721       <p><a name="4_4_checks"><strong>concept checks</strong></a>
722          If you see compilation errors containing messages about
723          <code> <em>foo</em>Concept </code>and a<code> constraints </code>
724          member function, then most likely you have violated one of the
725          requirements for types used during instantiation of template
726          containers and functions.  For example, EqualityComparableConcept
727          appears if your types must be comparable with == and you have not
728          provided this capability (a typo, or wrong visibility, or you
729          just plain forgot, etc).
730       </p>
731       <p>More information, including how to optionally enable/disable the
732          checks, is available
733          <a href="../19_diagnostics/howto.html#3">here</a>.
734       </p>
735       <p><a name="4_4_dlsym"><strong>dlopen/dlsym</strong></a>
736          If you are using the C++ library across dynamically-loaded
737          objects, make certain that you are passing the correct options
738          when compiling and linking:
739       </p>
740       <pre>
741     // compile the library components
742     g++ -fPIC -c a.cc
743     g++ -fPIC -c b.cc
744     ...
745     g++ -fPIC -c z.cc
746
747     // create the library
748     g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o
749
750     // link the executable
751     g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl</pre>
752
753 <hr />
754    <h2><a name="4_5">4.5 Aw, that's easy to fix!</a></h2>
755       <p>If you have found a bug in the library and you think you have
756          a working fix, then send it in!  The main GCC site has a page
757          on <a href="http://gcc.gnu.org/contribute.html">submitting
758          patches</a> that covers the procedure, but for libstdc++ you
759          should also send the patch to our mailing list in addition to
760          the GCC patches mailing list.  The libstdc++
761          <a href="../17_intro/contribute.html">contributors' page</a>
762          also talks about how to submit patches.
763       </p>
764       <p>In addition to the description, the patch, and the ChangeLog
765          entry, it is a Good Thing if you can additionally create a small
766          test program to test for the presence of the bug that your
767          patch fixes.  Bugs have a way of being reintroduced; if an old
768          bug creeps back in, it will be caught immediately by the 
769          <a href="#2_4">testsuite</a> -- but only if such a test exists.
770       </p>
771
772 <hr />
773 <h1><a name="5_0">5.0 Miscellaneous</a></h1>
774    <h2><a name="5_1">5.1 string::iterator is not char*;
775                      vector&lt;T&gt;::iterator is not T*</a></h2>
776       <p>If you have code that depends on container&lt;T&gt; iterators
777          being implemented as pointer-to-T, your code is broken.
778       </p>
779       <p>While there are arguments for iterators to be implemented in
780          that manner, A) they aren't very good ones in the long term,
781          and B) they were never guaranteed by the Standard anyway.  The
782          type-safety achieved by making iterators a real class rather
783          than a typedef for <code>T*</code> outweighs nearly all opposing
784          arguments.
785       </p>
786       <p>Code which does assume that a vector iterator <code> i </code>
787          is a pointer can often be fixed by changing <code> i </code> in
788          certain expressions to <code> &amp;*i </code>.  Future revisions
789          of the Standard are expected to bless this usage for
790          vector&lt;&gt; (but not for basic_string&lt;&gt;).
791       </p>
792
793 <hr />
794    <h2><a name="5_2">5.2 What's next after libstdc++-v3?</a></h2>
795       <p>Hopefully, not much.  The goal of libstdc++-v3 is to produce
796          a fully-compliant, fully-portable Standard Library.  After that,
797          we're mostly done:  there won't <em>be</em> any more compliance
798          work to do.  However:
799       </p>
800       <ol>
801       <li><p>The ISO Committee will meet periodically to review Defect Reports
802          in the C++ Standard.  Undoubtedly some of these will result in
803          changes to the Standard, which will be reflected in patches to
804          libstdc++.  Some of that is already happening, see 4.2.  Some of
805          those changes are being predicted by the library maintainers, and
806          we add code to the library based on what the current proposed
807          resolution specifies.  Those additions are listed in
808          <a href="../ext/howto.html#5">the extensions page</a>.
809       </p></li>
810       <li><p>Performance tuning.  Lots of performance tuning.  This too is
811          already underway for post-3.0 releases, starting with memory
812          expansion in container classes and buffer usage in synchronized
813          stream objects.
814       </p></li>
815       <li><p>An ABI for libstdc++ is being developed, so that
816          multiple binary-incompatible copies of the library can be replaced
817          with a single backwards-compatible library, like libgcc_s.so is.
818       </p></li>
819       <li><p>The current libstdc++ contains extensions to the Library which
820          must be explicitly requested by client code (for example, the
821          hash tables from SGI).  Other extensions may be added to
822          libstdc++-v3 if they seem to be &quot;standard&quot; enough.
823          (For example, the &quot;long long&quot; type from C99.)
824          Bugfixes and rewrites (to improve or fix thread safety, for
825          instance) will of course be a continuing task.
826       </p></li>
827       </ol>
828       <p><a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html">This
829          question</a> about the next libstdc++ prompted some brief but
830          interesting
831          <a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation</a>.
832       </p>
833
834 <hr />
835    <h2><a name="5_3">5.3 What about the STL from SGI?</a></h2>
836       <p>The <a href="http://www.sgi.com/Technology/STL/">STL from SGI</a>,
837          version 3.3, was the most recent merge of the STL codebase.  The
838          code in libstdc++ contains many fixes and changes, and it is
839          very likely that the SGI code is no longer under active
840          development.  We expect that no future merges will take place.
841       </p>
842       <p>In particular, <code>string</code> is not from SGI and makes no
843          use of their &quot;rope&quot; class (which is included as an
844          optional extension), nor is <code>valarray</code> and some others.
845          Classes like <code>vector&lt;&gt;</code> are, however.
846       </p>
847       <p>The FAQ for SGI's STL (one jump off of their main page) is
848          recommended reading.
849       </p>
850
851 <hr />
852    <h2><a name="5_4">5.4 Extensions and Backward Compatibility</a></h2>
853       <p>Headers in the <code>ext</code> and <code>backward</code>
854          subdirectories should be referred to by their relative paths:
855          <!-- Careful, the leading spaces in PRE show up directly. -->
856       </p>
857       <pre>
858       #include &lt;ext/hash_map&gt; </pre>
859       <p>rather than using <code>-I</code> or other options.  This is more
860          portable and forward-compatible.  (The situation is the same as
861          that of other headers whose directories are not searched directly,
862          e.g., <code>&lt;sys/stat.h&gt;</code>, <code>&lt;X11/Xlib.h&gt;</code>.
863       </p>
864       <p>Extensions to the library have
865          <a href="../ext/howto.html">their own page</a>.
866       </p>
867
868 <hr />
869    <h2><a name="5_5">5.5 [removed]</a></h2>
870       <p>This question has become moot and has been removed.  The stub
871          is here to preserve numbering (and hence links/bookmarks).
872       </p>
873
874 <hr />
875    <h2><a name="5_6">5.6 Is libstdc++-v3 thread-safe?</a></h2>
876       <p>When the system's libc is itself thread-safe, a non-generic
877          implementation of atomicity.h exists for the architecture, and gcc
878          itself reports a thread model other than single; libstdc++-v3
879          strives to be thread-safe.  The user-code must guard against
880          concurrent method calls which may access any particular library
881          object's state.  Typically, the application programmer may infer
882          what object locks must be held based on the objects referenced in
883          a method call.  Without getting into great detail, here is an
884          example which requires user-level locks:
885       </p>
886       <pre>
887      library_class_a shared_object_a;
888
889      thread_main () {
890        library_class_b *object_b = new library_class_b;
891        shared_object_a.add_b (object_b);   // must hold lock for shared_object_a
892        shared_object_a.mutate ();          // must hold lock for shared_object_a
893      }
894
895      // Multiple copies of thread_main() are started in independent threads.</pre>
896       <p>Under the assumption that object_a and object_b are never exposed to
897          another thread, here is an example that should not require any
898          user-level locks:
899       </p>
900       <pre>
901      thread_main () {
902        library_class_a object_a;
903        library_class_b *object_b = new library_class_b;
904        object_a.add_b (object_b);
905        object_a.mutate ();
906      } </pre>
907       <p>All library objects are safe to use in a multithreaded program as
908          long as each thread carefully locks out access by any other thread
909          while it uses any object visible to another thread.  In general,
910          this requirement includes both read and write access to objects;
911          unless otherwise documented as safe, do not assume that two
912          threads may access a shared standard library object at the
913          same time.
914       </p>
915       <p>See chapters <a href="../17_intro/howto.html#3">17</a> (library
916          introduction), <a href="../23_containers/howto.html#3">23</a>
917          (containers), and <a href="../27_io/howto.html#9">27</a> (I/O) for
918          more information.
919       </p>
920
921 <hr />
922    <h2><a name="5_7">5.7 How do I get a copy of the ISO C++ Standard?</a></h2>
923       <p>Copies of the full ISO 14882 standard are available on line via the
924          ISO mirror site for committee members.  Non-members, or those who
925          have not paid for the privilege of sitting on the committee and
926          sustained their two-meeting commitment for voting rights, may get a
927          copy of the standard from their respective national standards
928          organization.  In the USA, this national standards organization is
929          ANSI and their website is right <a href="http://www.ansi.org">here</a>.
930          (And if you've already registered with them, clicking this link will
931          take you to directly to the place where you can
932 <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998">buy
933          the standard on-line</a>.
934       </p>
935       <p>Who is your country's member body?  Visit the
936          <a href="http://www.iso.ch/">ISO homepage</a> and find out!
937       </p>
938
939 <hr />
940    <h2><a name="5_8">5.8 What's an ABI and why is it so messy?</a></h2>
941       <p>&quot;ABI&quot; stands for &quot;Application Binary Interface.&quot;
942          Conventionally, it refers to a great mass of details about how
943          arguments are arranged on the call stack and/or in registers, and
944          how various types are arranged and padded in structs.  A single CPU
945          design may suffer multiple ABIs designed by different development
946          tool vendors who made different choices, or even by the same vendor
947          for different target applications or compiler versions.  In ideal
948          circumstances the CPU designer presents one ABI and all the OSes and
949          compilers use it.  In practice every ABI omits details that compiler
950          implementers (consciously or accidentally) must choose for themselves.
951       </p>
952       <p>That ABI definition suffices for compilers to generate code so a
953          program can interact safely with an OS and its lowest-level libraries.
954          Users usually want an ABI to encompass more detail, allowing libraries
955          built with different compilers (or different releases of the same
956          compiler!) to be linked together.  For C++, this includes many more
957          details than for C, and CPU designers (for good reasons elaborated
958          below) have not stepped up to publish C++ ABIs.  The details include
959          virtual function implementation, struct inheritance layout, name
960          mangling, and exception handling.  Such an ABI has been defined for
961          GNU C++, and is immediately useful for embedded work relying only on
962          a &quot;free-standing implementation&quot; that doesn't include (much
963          of) the standard library.  It is a good basis for the work to come.
964       </p>
965       <p>A useful C++ ABI must also incorporate many details of the standard 
966          library implementation.  For a C ABI, the layouts of a few structs
967          (such as FILE, stat, jmpbuf, and the like) and a few macros suffice.
968          For C++, the details include the complete set of names of functions
969          and types used, the offsets of class members and virtual functions,
970          and the actual definitions of all inlines.  C++ exposes many more
971          library details to the caller than C does.  It makes defining
972          a complete ABI a much bigger undertaking, and requires not just
973          documenting library implementation details, but carefully designing
974          those details so that future bug fixes and optimizations don't
975          force breaking the ABI.
976       </p>
977       <p>There are ways to help isolate library implementation details from the 
978          ABI, but they trade off against speed.  Library details used in
979          inner loops (e.g., getchar) must be exposed and frozen for all
980          time, but many others may reasonably be kept hidden from user code,
981          so they may later be changed.  Deciding which, and implementing
982          the decisions, must happen before you can reasonably document a
983          candidate C++ ABI that encompasses the standard library.
984       </p>
985
986 <!-- ####################################################### -->
987
988 <hr />
989 <p class="fineprint"><em>
990 See <a href="../17_intro/license.html">license.html</a> for copying conditions.
991 Comments and suggestions are welcome, and may be sent to
992 <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
993 </em></p>
994
995
996 </body>
997 </html>
998