xref: /openbsd-src/gnu/gcc/libstdc++-v3/docs/html/faq/index.txt (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert
2*404b540aSrobert   #[1]GNU C++ Standard Library [2]Copyright
3*404b540aSrobert
4*404b540aSrobert                     libstdc++ Frequently Asked Questions
5*404b540aSrobert
6*404b540aSrobert   The latest version of this document is always available at
7*404b540aSrobert   [3]http://gcc.gnu.org/onlinedocs/libstdc++/faq/. The main
8*404b540aSrobert   documentation page is at
9*404b540aSrobert   [4]http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html.
10*404b540aSrobert
11*404b540aSrobert   To the [5]libstdc++-v3 homepage.
12*404b540aSrobert     _________________________________________________________________
13*404b540aSrobert
14*404b540aSrobert                                   Questions
15*404b540aSrobert
16*404b540aSrobert    1. [6]General Information
17*404b540aSrobert         1. [7]What is libstdc++-v3?
18*404b540aSrobert         2. [8]Why should I use libstdc++?
19*404b540aSrobert         3. [9]Who's in charge of it?
20*404b540aSrobert         4. [10]How do I get libstdc++?
21*404b540aSrobert         5. [11]When is libstdc++ going to be finished?
22*404b540aSrobert         6. [12]How do I contribute to the effort?
23*404b540aSrobert         7. [13]What happened to libg++? I need that!
24*404b540aSrobert         8. [14]What if I have more questions?
25*404b540aSrobert         9. [15]What are the license terms for libstdc++-v3?
26*404b540aSrobert    2. [16]Installation
27*404b540aSrobert         1. [17]How do I install libstdc++-v3?
28*404b540aSrobert         2. [18][removed]
29*404b540aSrobert         3. [19]What is this SVN thing that you keep mentioning?
30*404b540aSrobert         4. [20]How do I know if it works?
31*404b540aSrobert         5. [21]This library is HUGE! And what's libsupc++?
32*404b540aSrobert         6. [22]Why do I get an error saying libstdc++.so.X is missing
33*404b540aSrobert            when I run my program?
34*404b540aSrobert    3. [23]Platform-Specific Issues
35*404b540aSrobert         1. [24]Can libstdc++-v3 be used with <my favorite compiler>?
36*404b540aSrobert         2. [25][removed]
37*404b540aSrobert         3. [26][removed]
38*404b540aSrobert         4. [27]I can't use 'long long' on Solaris
39*404b540aSrobert         5. [28]_XOPEN_SOURCE / _GNU_SOURCE / etc is always defined
40*404b540aSrobert         6. [29]OS X ctype.h is broken! How can I hack it?
41*404b540aSrobert         7. [30]Threading is broken on i386
42*404b540aSrobert         8. [31]Recent GNU/Linux glibc required?
43*404b540aSrobert         9. [32]Can't use wchar_t/wstring on FreeBSD
44*404b540aSrobert        10. [33]MIPS atomic operations
45*404b540aSrobert    4. [34]Known Bugs and Non-Bugs
46*404b540aSrobert         1. [35]What works already?
47*404b540aSrobert         2. [36]Bugs in gcc/g++ (not libstdc++-v3)
48*404b540aSrobert         3. [37]Bugs in the C++ language/lib specification
49*404b540aSrobert         4. [38]Things in libstdc++ that only look like bugs
50*404b540aSrobert               o [39]reopening a stream fails
51*404b540aSrobert               o [40]-Weffc++ complains too much
52*404b540aSrobert               o [41]"ambiguous overloads" after including an old-style
53*404b540aSrobert                 header
54*404b540aSrobert               o [42]The g++-3 headers are not ours
55*404b540aSrobert               o [43]compilation errors from streambuf.h
56*404b540aSrobert               o [44]errors about *Concept and constraints in the STL...
57*404b540aSrobert               o [45]program crashes when using library code in a
58*404b540aSrobert                 dynamically-loaded library
59*404b540aSrobert               o [46]"memory leaks" in containers
60*404b540aSrobert         5. [47]Aw, that's easy to fix!
61*404b540aSrobert    5. [48]Miscellaneous
62*404b540aSrobert         1. [49]string::iterator is not char*; vector<T>::iterator is not
63*404b540aSrobert            T*
64*404b540aSrobert         2. [50]What's next after libstdc++-v3?
65*404b540aSrobert         3. [51]What about the STL from SGI?
66*404b540aSrobert         4. [52]Extensions and Backward Compatibility
67*404b540aSrobert         5. [53]Does libstdc++ support TR1?
68*404b540aSrobert         6. [54]Is libstdc++-v3 thread-safe?
69*404b540aSrobert         7. [55]How do I get a copy of the ISO C++ Standard?
70*404b540aSrobert         8. [56]What's an ABI and why is it so messy?
71*404b540aSrobert         9. [57]How do I make std::vector<T>::capacity() ==
72*404b540aSrobert            std::vector<T>::size?
73*404b540aSrobert     _________________________________________________________________
74*404b540aSrobert
75*404b540aSrobert                            1.0 General Information
76*404b540aSrobert
77*404b540aSrobert1.1 What is libstdc++-v3?
78*404b540aSrobert
79*404b540aSrobert   The GNU Standard C++ Library v3 is an ongoing project to implement the
80*404b540aSrobert   ISO 14882 Standard C++ library as described in chapters 17 through 27
81*404b540aSrobert   and annex D. For those who want to see exactly how far the project has
82*404b540aSrobert   come, or just want the latest bleeding-edge code, the up-to-date
83*404b540aSrobert   source is available over anonymous SVN, and can even be browsed over
84*404b540aSrobert   the Web (see [58]1.4 below).
85*404b540aSrobert
86*404b540aSrobert   The older libstdc++-v2 project is no longer maintained; the code has
87*404b540aSrobert   been completely replaced and rewritten. [59]If you are using V2, then
88*404b540aSrobert   you need to report bugs to your system vendor, not to the V3 list.
89*404b540aSrobert
90*404b540aSrobert   A more formal description of the V3 goals can be found in the official
91*404b540aSrobert   [60]design document.
92*404b540aSrobert     _________________________________________________________________
93*404b540aSrobert
94*404b540aSrobert1.2 Why should I use libstdc++?
95*404b540aSrobert
96*404b540aSrobert   The completion of the ISO C++ standardization gave the C++ community a
97*404b540aSrobert   powerful set of reuseable tools in the form of the C++ Standard
98*404b540aSrobert   Library. However, all existing C++ implementations are (as the Draft
99*404b540aSrobert   Standard used to say) "incomplet and incorrekt," and many suffer from
100*404b540aSrobert   limitations of the compilers that use them.
101*404b540aSrobert
102*404b540aSrobert   The GNU C/C++/FORTRAN/<pick-a-language> compiler (gcc, g++, etc) is
103*404b540aSrobert   widely considered to be one of the leading compilers in the world. Its
104*404b540aSrobert   development is overseen by the [61]GCC team. All of the rapid
105*404b540aSrobert   development and near-legendary [62]portability that are the hallmarks
106*404b540aSrobert   of an open-source project are being applied to libstdc++.
107*404b540aSrobert
108*404b540aSrobert   That means that all of the Standard classes and functions (such as
109*404b540aSrobert   string, vector<>, iostreams, and algorithms) will be freely available
110*404b540aSrobert   and fully compliant. Programmers will no longer need to "roll their
111*404b540aSrobert   own" nor be worried about platform-specific incompatibilities.
112*404b540aSrobert     _________________________________________________________________
113*404b540aSrobert
114*404b540aSrobert1.3 Who's in charge of it?
115*404b540aSrobert
116*404b540aSrobert   The libstdc++ project is contributed to by several developers all over
117*404b540aSrobert   the world, in the same way as GCC or Linux. Benjamin Kosnik, Gabriel
118*404b540aSrobert   Dos Reis, Phil Edwards, Ulrich Drepper, Loren James Rittle, and Paolo
119*404b540aSrobert   Carlini are the lead maintainers of the SVN archive.
120*404b540aSrobert
121*404b540aSrobert   Development and discussion is held on the libstdc++ mailing list.
122*404b540aSrobert   Subscribing to the list, or searching the list archives, is open to
123*404b540aSrobert   everyone. You can read instructions for doing so on the [63]homepage.
124*404b540aSrobert   If you have questions, ideas, code, or are just curious, sign up!
125*404b540aSrobert     _________________________________________________________________
126*404b540aSrobert
127*404b540aSrobert1.4 How do I get libstdc++?
128*404b540aSrobert
129*404b540aSrobert   The [64]homepage has instructions for retrieving the latest SVN
130*404b540aSrobert   sources, and for browsing the SVN sources over the web.
131*404b540aSrobert
132*404b540aSrobert   Stable versions of libstdc++-v3 are included with releases of [65]the
133*404b540aSrobert   GCC compilers.
134*404b540aSrobert
135*404b540aSrobert   The subset commonly known as the Standard Template Library (chapters
136*404b540aSrobert   23 through 25, mostly) is adapted from the final release of the SGI
137*404b540aSrobert   STL, with extensive changes.
138*404b540aSrobert     _________________________________________________________________
139*404b540aSrobert
140*404b540aSrobert1.5 When is libstdc++ going to be finished?
141*404b540aSrobert
142*404b540aSrobert   Nathan Myers gave the best of all possible answers, responding to a
143*404b540aSrobert   Usenet article asking this question: Sooner, if you help.
144*404b540aSrobert     _________________________________________________________________
145*404b540aSrobert
146*404b540aSrobert1.6 How do I contribute to the effort?
147*404b540aSrobert
148*404b540aSrobert   Here is [66]a page devoted to this topic. Subscribing to the mailing
149*404b540aSrobert   list (see above, or the homepage) is a very good idea if you have
150*404b540aSrobert   something to contribute, or if you have spare time and want to help.
151*404b540aSrobert   Contributions don't have to be in the form of source code; anybody who
152*404b540aSrobert   is willing to help write documentation, for example, or has found a
153*404b540aSrobert   bug in code that we all thought was working, is more than welcome!
154*404b540aSrobert     _________________________________________________________________
155*404b540aSrobert
156*404b540aSrobert1.7 What happened to libg++? I need that!
157*404b540aSrobert
158*404b540aSrobert   The most recent libg++ README states that libg++ is no longer being
159*404b540aSrobert   actively maintained. It should not be used for new projects, and is
160*404b540aSrobert   only being kicked along to support older code.
161*404b540aSrobert
162*404b540aSrobert   The libg++ was designed and created when there was no Standard to
163*404b540aSrobert   provide guidance. Classes like linked lists are now provided for by
164*404b540aSrobert   list<T> and do not need to be created by genclass. (For that matter,
165*404b540aSrobert   templates exist now and are well-supported, whereas genclass (mostly)
166*404b540aSrobert   predates them.)
167*404b540aSrobert
168*404b540aSrobert   There are other classes in libg++ that are not specified in the ISO
169*404b540aSrobert   Standard (e.g., statistical analysis). While there are a lot of really
170*404b540aSrobert   useful things that are used by a lot of people (e.g., statistics :-),
171*404b540aSrobert   the Standards Committee couldn't include everything, and so a lot of
172*404b540aSrobert   those "obvious" classes didn't get included.
173*404b540aSrobert
174*404b540aSrobert   Since libstdc++ is an implementation of the Standard Library, we have
175*404b540aSrobert   no plans at this time to include non-Standard utilities in the
176*404b540aSrobert   implementation, however handy they are. (The extensions provided in
177*404b540aSrobert   the SGI STL aren't maintained by us and don't get a lot of our
178*404b540aSrobert   attention, because they don't require a lot of our time.) It is
179*404b540aSrobert   entirely plausable that the "useful stuff" from libg++ might be
180*404b540aSrobert   extracted into an updated utilities library, but nobody has started
181*404b540aSrobert   such a project yet.
182*404b540aSrobert
183*404b540aSrobert   (The [67]Boost site houses free C++ libraries that do varying things,
184*404b540aSrobert   and happened to be started by members of the Standards Committee.
185*404b540aSrobert   Certain "useful stuff" classes will probably migrate there.)
186*404b540aSrobert
187*404b540aSrobert   For the bold and/or desperate, the [68]GCC extensions page describes
188*404b540aSrobert   where to find the last libg++ source.
189*404b540aSrobert     _________________________________________________________________
190*404b540aSrobert
191*404b540aSrobert1.8 What if I have more questions?
192*404b540aSrobert
193*404b540aSrobert   If you have read the README and RELEASE-NOTES files, and your question
194*404b540aSrobert   remains unanswered, then just ask the mailing list. At present, you do
195*404b540aSrobert   not need to be subscribed to the list to send a message to it. More
196*404b540aSrobert   information is available on the homepage (including how to browse the
197*404b540aSrobert   list archives); to send to the list, use [69]libstdc++@gcc.gnu.org.
198*404b540aSrobert
199*404b540aSrobert   If you have a question that you think should be included here, or if
200*404b540aSrobert   you have a question about a question/answer here, contact [70]Phil
201*404b540aSrobert   Edwards or [71]Gabriel Dos Reis.
202*404b540aSrobert     _________________________________________________________________
203*404b540aSrobert
204*404b540aSrobert1.9 What are the license terms for libstdc++-v3?
205*404b540aSrobert
206*404b540aSrobert   See [72]our license description for these and related questions.
207*404b540aSrobert     _________________________________________________________________
208*404b540aSrobert
209*404b540aSrobert                               2.0 Installation
210*404b540aSrobert
211*404b540aSrobert2.1 How do I install libstdc++-v3?
212*404b540aSrobert
213*404b540aSrobert   Complete instructions are not given here (this is a FAQ, not an
214*404b540aSrobert   installation document), but the tools required are few:
215*404b540aSrobert     * A 3.x release of GCC. Note that building GCC is much easier and
216*404b540aSrobert       more automated than building the GCC 2.[78] series was. If you are
217*404b540aSrobert       using GCC 2.95, you can still build earlier snapshots of
218*404b540aSrobert       libstdc++.
219*404b540aSrobert     * GNU Make is required for GCC 3.4 and later.
220*404b540aSrobert     * The GNU Autotools are needed if you are messing with the configury
221*404b540aSrobert       or makefiles.
222*404b540aSrobert
223*404b540aSrobert   The file [73]documentation.html provides a good overview of the steps
224*404b540aSrobert   necessary to build, install, and use the library. Instructions for
225*404b540aSrobert   configuring the library with new flags such as --enable-threads are
226*404b540aSrobert   there also, as well as patches and instructions for working with GCC
227*404b540aSrobert   2.95.
228*404b540aSrobert
229*404b540aSrobert   The top-level install.html and [74]RELEASE-NOTES files contain the
230*404b540aSrobert   exact build and installation instructions. You may wish to browse
231*404b540aSrobert   those files over ViewVC ahead of time to get a feel for what's
232*404b540aSrobert   required. RELEASE-NOTES is located in the ".../docs/17_intro/"
233*404b540aSrobert   directory of the distribution.
234*404b540aSrobert     _________________________________________________________________
235*404b540aSrobert
236*404b540aSrobert2.2 [removed]
237*404b540aSrobert
238*404b540aSrobert   This question has become moot and has been removed. The stub is here
239*404b540aSrobert   to preserve numbering (and hence links/bookmarks).
240*404b540aSrobert     _________________________________________________________________
241*404b540aSrobert
242*404b540aSrobert2.3 What is this SVN thing that you keep mentioning?
243*404b540aSrobert
244*404b540aSrobert   Subversion is one of several revision control packages. It was
245*404b540aSrobert   selected for GNU projects because it's free (speech), free (beer), and
246*404b540aSrobert   very high quality. The [75]Subversion home page has a better
247*404b540aSrobert   description.
248*404b540aSrobert
249*404b540aSrobert   The "anonymous client checkout" feature of SVN is similar to anonymous
250*404b540aSrobert   FTP in that it allows anyone to retrieve the latest libstdc++ sources.
251*404b540aSrobert
252*404b540aSrobert   After the first of April, American users will have a "/pharmacy"
253*404b540aSrobert   command-line option...
254*404b540aSrobert     _________________________________________________________________
255*404b540aSrobert
256*404b540aSrobert2.4 How do I know if it works?
257*404b540aSrobert
258*404b540aSrobert   libstdc++-v3 comes with its own testsuite. You do not need to actually
259*404b540aSrobert   install the library ("make install") to run the testsuite, but you do
260*404b540aSrobert   need DejaGNU, as described [76]here.
261*404b540aSrobert
262*404b540aSrobert   To run the testsuite on the library after building it, use "make
263*404b540aSrobert   check" while in your build directory. To run the testsuite on the
264*404b540aSrobert   library after building and installing it, use "make check-install"
265*404b540aSrobert   instead.
266*404b540aSrobert
267*404b540aSrobert   If you find bugs in the testsuite programs themselves, or if you think
268*404b540aSrobert   of a new test program that should be added to the suite, please write
269*404b540aSrobert   up your idea and send it to the list!
270*404b540aSrobert     _________________________________________________________________
271*404b540aSrobert
272*404b540aSrobert2.5 This library is HUGE! And what's libsupc++?
273*404b540aSrobert
274*404b540aSrobert   Usually the size of libraries on disk isn't noticeable. When a link
275*404b540aSrobert   editor (or simply "linker") pulls things from a static archive
276*404b540aSrobert   library, only the necessary object files are copied into your
277*404b540aSrobert   executable, not the entire library. Unfortunately, even if you only
278*404b540aSrobert   need a single function or variable from an object file, the entire
279*404b540aSrobert   object file is extracted. (There's nothing unique to C++ or
280*404b540aSrobert   libstdc++-v3 about this; it's just common behavior, given here for
281*404b540aSrobert   background reasons.)
282*404b540aSrobert
283*404b540aSrobert   Some of the object files which make up libstdc++.a are rather large.
284*404b540aSrobert   If you create a statically-linked executable with -static, those large
285*404b540aSrobert   object files are suddenly part of your executable. Historically the
286*404b540aSrobert   best way around this was to only place a very few functions (often
287*404b540aSrobert   only a single one) in each source/object file; then extracting a
288*404b540aSrobert   single function is the same as extracting a single .o file. For
289*404b540aSrobert   libstdc++-v3 this is only possible to a certain extent; the object
290*404b540aSrobert   files in question contain template classes and template functions,
291*404b540aSrobert   pre-instantiated, and splitting those up causes severe maintenance
292*404b540aSrobert   headaches.
293*404b540aSrobert
294*404b540aSrobert   It's not a bug, and it's not really a problem. Nevertheless, some
295*404b540aSrobert   people don't like it, so here are two pseudo-solutions:
296*404b540aSrobert
297*404b540aSrobert   If the only functions from libstdc++.a which you need are language
298*404b540aSrobert   support functions (those listed in [77]clause 18 of the standard,
299*404b540aSrobert   e.g., new and delete), then try linking against libsupc++.a (Using gcc
300*404b540aSrobert   instead of g++ and explicitly linking in -lsupc++ for the final link
301*404b540aSrobert   step will do it). This library contains only those support routines,
302*404b540aSrobert   one per object file. But if you are using anything from the rest of
303*404b540aSrobert   the library, such as IOStreams or vectors, then you'll still need
304*404b540aSrobert   pieces from libstdc++.a.
305*404b540aSrobert
306*404b540aSrobert   The second method is one we hope to incorporate into the library build
307*404b540aSrobert   process. Some platforms can place each function and variable into its
308*404b540aSrobert   own section in a .o file. The GNU linker can then perform garbage
309*404b540aSrobert   collection on unused sections; this reduces the situation to only
310*404b540aSrobert   copying needed functions into the executable, as before, but all
311*404b540aSrobert   happens automatically.
312*404b540aSrobert
313*404b540aSrobert   Unfortunately the garbage collection in GNU ld is buggy; sections
314*404b540aSrobert   (corresponding to functions and variables) which are used are
315*404b540aSrobert   mistakenly removed, leading to horrible crashes when your executable
316*404b540aSrobert   starts up. For the time being, this feature is not used when building
317*404b540aSrobert   the library.
318*404b540aSrobert     _________________________________________________________________
319*404b540aSrobert
320*404b540aSrobert2.6 Why do I get an error saying libstdc++.so.X is missing when I run my
321*404b540aSrobertprogram?
322*404b540aSrobert
323*404b540aSrobert   Depending on your platform and library version, the message might be
324*404b540aSrobert   similar to one of the following:
325*404b540aSrobert    ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open
326*404b540aSrobertshared object file: No such file or directory
327*404b540aSrobert
328*404b540aSrobert    /usr/libexec/ld-elf.so.1: Shared object "libstdc++.so.6" not found
329*404b540aSrobert
330*404b540aSrobert   This doesn't mean that the shared library isn't installed, only that
331*404b540aSrobert   the dynamic linker can't find it. When a dynamically-linked executable
332*404b540aSrobert   is run the linker finds and loads the required shared libraries by
333*404b540aSrobert   searching a pre-configured list of directories. If the directory where
334*404b540aSrobert   you've installed libstdc++ is not in this list then the libraries
335*404b540aSrobert   won't be found. The simplest way to fix this is to use the
336*404b540aSrobert   LD_LIBRARY_PATH environment variable, which is a colon-separated list
337*404b540aSrobert   of directories in which the linker will search for shared libraries:
338*404b540aSrobert    LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH
339*404b540aSrobert    export LD_LIBRARY_PATH
340*404b540aSrobert
341*404b540aSrobert   The exact environment variable to use will depend on your platform,
342*404b540aSrobert   e.g. DYLD_LIBRARY_PATH for Darwin,
343*404b540aSrobert   LD_LIBRARY_PATH_32/LD_LIBRARY_PATH_64 for Solaris 32-/64-bit,
344*404b540aSrobert   LD_LIBRARYN32_PATH/LD_LIBRARY64_PATH for Irix N32/64-bit ABIs and
345*404b540aSrobert   SHLIB_PATH for HP-UX.
346*404b540aSrobert
347*404b540aSrobert   See the man pages for ld(1), ldd(1) and ldconfig(8) for more
348*404b540aSrobert   information. The dynamic linker has different names on different
349*404b540aSrobert   platforms but the man page is usually called something such as ld.so /
350*404b540aSrobert   rtld / dld.so.
351*404b540aSrobert     _________________________________________________________________
352*404b540aSrobert
353*404b540aSrobert                         3.0 Platform-Specific Issues
354*404b540aSrobert
355*404b540aSrobert3.1 Can libstdc++-v3 be used with <my favorite compiler>?
356*404b540aSrobert
357*404b540aSrobert   Probably not. Yet.
358*404b540aSrobert
359*404b540aSrobert   Because GCC advances so rapidly, development and testing of libstdc++
360*404b540aSrobert   is being done almost entirely under that compiler. If you are curious
361*404b540aSrobert   about whether other, lesser compilers (*grin*) support libstdc++, you
362*404b540aSrobert   are more than welcome to try. Configuring and building the library
363*404b540aSrobert   (see above) will still require certain tools, however. Also keep in
364*404b540aSrobert   mind that building libstdc++ does not imply that your compiler will be
365*404b540aSrobert   able to use all of the features found in the C++ Standard Library.
366*404b540aSrobert
367*404b540aSrobert   Since the goal of ISO Standardization is for all C++ implementations
368*404b540aSrobert   to be able to share code, the final libstdc++ should, in theory, be
369*404b540aSrobert   usable under any ISO-compliant compiler. It will still be targeted and
370*404b540aSrobert   optimized for GCC/g++, however.
371*404b540aSrobert     _________________________________________________________________
372*404b540aSrobert
373*404b540aSrobert3.2 [removed]
374*404b540aSrobert
375*404b540aSrobert   This question has become moot and has been removed. The stub is here
376*404b540aSrobert   to preserve numbering (and hence links/bookmarks).
377*404b540aSrobert     _________________________________________________________________
378*404b540aSrobert
379*404b540aSrobert3.3 [removed]
380*404b540aSrobert
381*404b540aSrobert   This question has become moot and has been removed. The stub is here
382*404b540aSrobert   to preserve numbering (and hence links/bookmarks).
383*404b540aSrobert     _________________________________________________________________
384*404b540aSrobert
385*404b540aSrobert3.4 I can't use 'long long' on Solaris
386*404b540aSrobert
387*404b540aSrobert   By default we try to support the C99 long long type. This requires
388*404b540aSrobert   that certain functions from your C library be present.
389*404b540aSrobert
390*404b540aSrobert   Up through release 3.0.2 the tests performed were too general, and
391*404b540aSrobert   this feature was disabled when it did not need to be. The most
392*404b540aSrobert   commonly reported platform affected was Solaris.
393*404b540aSrobert
394*404b540aSrobert   This has been fixed for 3.0.3 and onwards.
395*404b540aSrobert     _________________________________________________________________
396*404b540aSrobert
397*404b540aSrobert3.5 _XOPEN_SOURCE / _GNU_SOURCE / etc is always defined
398*404b540aSrobert
399*404b540aSrobert   On Solaris, g++ (but not gcc) always defines the preprocessor macro
400*404b540aSrobert   _XOPEN_SOURCE. On GNU/Linux, the same happens with _GNU_SOURCE. (This
401*404b540aSrobert   is not an exhaustive list; other macros and other platforms are also
402*404b540aSrobert   affected.)
403*404b540aSrobert
404*404b540aSrobert   These macros are typically used in C library headers, guarding new
405*404b540aSrobert   versions of functions from their older versions. The C++ standard
406*404b540aSrobert   library includes the C standard library, but it requires the C90
407*404b540aSrobert   version, which for backwards-compatability reasons is often not the
408*404b540aSrobert   default for many vendors.
409*404b540aSrobert
410*404b540aSrobert   More to the point, the C++ standard requires behavior which is only
411*404b540aSrobert   available on certain platforms after certain symbols are defined.
412*404b540aSrobert   Usually the issue involves I/O-related typedefs. In order to ensure
413*404b540aSrobert   correctness, the compiler simply predefines those symbols.
414*404b540aSrobert
415*404b540aSrobert   Note that it's not enough to #define them only when the library is
416*404b540aSrobert   being built (during installation). Since we don't have an 'export'
417*404b540aSrobert   keyword, much of the library exists as headers, which means that the
418*404b540aSrobert   symbols must also be defined as your programs are parsed and compiled.
419*404b540aSrobert
420*404b540aSrobert   To see which symbols are defined, look for CPLUSPLUS_CPP_SPEC in the
421*404b540aSrobert   gcc config headers for your target (and try changing them to see what
422*404b540aSrobert   happens when building complicated code). You can also run "g++ -E -dM
423*404b540aSrobert   - < /dev/null" to display a list of predefined macros for any
424*404b540aSrobert   particular installation.
425*404b540aSrobert
426*404b540aSrobert   This has been discussed on the mailing lists [78]quite a bit.
427*404b540aSrobert
428*404b540aSrobert   This method is something of a wart. We'd like to find a cleaner
429*404b540aSrobert   solution, but nobody yet has contributed the time.
430*404b540aSrobert     _________________________________________________________________
431*404b540aSrobert
432*404b540aSrobert3.6 OS X ctype.h is broken! How can I hack it?
433*404b540aSrobert
434*404b540aSrobert   This is a long-standing bug in the OS X support. Fortunately, the
435*404b540aSrobert   patch is quite simple, and well-known. [79]Here's a link to the
436*404b540aSrobert   solution.
437*404b540aSrobert     _________________________________________________________________
438*404b540aSrobert
439*404b540aSrobert3.7 Threading is broken on i386
440*404b540aSrobert
441*404b540aSrobert   Support for atomic integer operations is/was broken on i386 platforms.
442*404b540aSrobert   The assembly code accidentally used opcodes that are only available on
443*404b540aSrobert   the i486 and later. So if you configured GCC to target, for example,
444*404b540aSrobert   i386-linux, but actually used the programs on an i686, then you would
445*404b540aSrobert   encounter no problems. Only when actually running the code on a i386
446*404b540aSrobert   will the problem appear.
447*404b540aSrobert
448*404b540aSrobert   This is fixed in 3.2.2.
449*404b540aSrobert     _________________________________________________________________
450*404b540aSrobert
451*404b540aSrobert3.8 Recent GNU/Linux glibc required?
452*404b540aSrobert
453*404b540aSrobert   When running on GNU/Linux, libstdc++ 3.2.1 (shared library version
454*404b540aSrobert   5.0.1) and later uses localization and formatting code from the system
455*404b540aSrobert   C library (glibc) version 2.2.5. That version of glibc is over a year
456*404b540aSrobert   old and contains necessary bugfixes. Many GNU/Linux distros make glibc
457*404b540aSrobert   version 2.3.x available now.
458*404b540aSrobert
459*404b540aSrobert   The guideline is simple: the more recent the C++ library, the more
460*404b540aSrobert   recent the C library. (This is also documented in the main GCC
461*404b540aSrobert   installation instructions.)
462*404b540aSrobert     _________________________________________________________________
463*404b540aSrobert
464*404b540aSrobert3.9 Can't use wchar_t/wstring on FreeBSD
465*404b540aSrobert
466*404b540aSrobert   At the moment there are a few problems in FreeBSD's support for wide
467*404b540aSrobert   character functions, and as a result the libstdc++ configury decides
468*404b540aSrobert   that wchar_t support should be disabled. Once the underlying problems
469*404b540aSrobert   are fixed in FreeBSD (soon), the library support will automatically
470*404b540aSrobert   enable itself.
471*404b540aSrobert
472*404b540aSrobert   You can fix the problems yourself, and learn more about the situation,
473*404b540aSrobert   by reading [80]this short thread ("_GLIBCPP_USE_WCHAR_T undefined in
474*404b540aSrobert   FreeBSD's c++config.h?").
475*404b540aSrobert     _________________________________________________________________
476*404b540aSrobert
477*404b540aSrobert3.10 MIPS atomic operations
478*404b540aSrobert
479*404b540aSrobert   The atomic locking routines for MIPS targets requires MIPS II and
480*404b540aSrobert   later. A patch went in just after the 3.3 release to make mips* use
481*404b540aSrobert   the generic implementation instead. You can also configure for
482*404b540aSrobert   mipsel-elf as a workaround.
483*404b540aSrobert
484*404b540aSrobert   mips*-*-linux* continues to use the MIPS II routines, and more work in
485*404b540aSrobert   this area is expected.
486*404b540aSrobert     _________________________________________________________________
487*404b540aSrobert
488*404b540aSrobert                          4.0 Known Bugs and Non-Bugs
489*404b540aSrobert
490*404b540aSrobert   Note that this section can get rapdily outdated -- such is the nature
491*404b540aSrobert   of an open-source project. For the latest information, join the
492*404b540aSrobert   mailing list or look through recent archives. The RELEASE- NOTES and
493*404b540aSrobert   BUGS files are generally kept up-to-date.
494*404b540aSrobert
495*404b540aSrobert   For 3.0.1, the most common "bug" is an apparently missing "../" in
496*404b540aSrobert   include/Makefile, resulting in files like gthr.h and gthr-single.h not
497*404b540aSrobert   being found. Please read [81]the configuration instructions for GCC,
498*404b540aSrobert   specifically the part about configuring in a separate build directory,
499*404b540aSrobert   and how strongly recommended it is. Building in the source directory
500*404b540aSrobert   is fragile, is rarely tested, and tends to break, as in this case.
501*404b540aSrobert   This was fixed for 3.0.2.
502*404b540aSrobert
503*404b540aSrobert   For 3.1, the most common "bug" is a parse error when using <fstream>,
504*404b540aSrobert   ending with a message, "bits/basic_file.h:52: parse error before `{'
505*404b540aSrobert   token." Please read [82]the installation instructions for GCC,
506*404b540aSrobert   specifically the part about not installing newer versions on top of
507*404b540aSrobert   older versions. If you install 3.1 over a 3.0.x release, then the
508*404b540aSrobert   wrong basic_file.h header will be found (its location changed between
509*404b540aSrobert   releases).
510*404b540aSrobert
511*404b540aSrobert   Please do not report these as bugs. We know about them. Reporting this
512*404b540aSrobert   -- or any other problem that's already been fixed -- hinders the
513*404b540aSrobert   development of GCC, because we have to take time to respond to your
514*404b540aSrobert   report. Thank you.
515*404b540aSrobert     _________________________________________________________________
516*404b540aSrobert
517*404b540aSrobert4.1 What works already?
518*404b540aSrobert
519*404b540aSrobert   Short answer: Pretty much everything works except for some corner
520*404b540aSrobert   cases. Also, localization is incomplete. For whether it works well, or
521*404b540aSrobert   as you expect it to work, see 5.2.
522*404b540aSrobert
523*404b540aSrobert   Long answer: See the docs/html/17_intro/CHECKLIST file, which is badly
524*404b540aSrobert   outdated... Also see the RELEASE-NOTES file, which is kept more up to
525*404b540aSrobert   date.
526*404b540aSrobert     _________________________________________________________________
527*404b540aSrobert
528*404b540aSrobert4.2 Bugs in gcc/g++ (not libstdc++-v3)
529*404b540aSrobert
530*404b540aSrobert   This is by no means meant to be complete nor exhaustive, but mentions
531*404b540aSrobert   some problems that users may encounter when building or using
532*404b540aSrobert   libstdc++. If you are experiencing one of these problems, you can find
533*404b540aSrobert   more information on the libstdc++ and the GCC mailing lists.
534*404b540aSrobert
535*404b540aSrobert   Before reporting a bug, examine the [83]bugs database with the
536*404b540aSrobert   category set to "libstdc++". The BUGS file in the source tree also
537*404b540aSrobert   tracks known serious problems.
538*404b540aSrobert     * Debugging is problematic, due to bugs in line-number generation
539*404b540aSrobert       (mostly fixed in the compiler) and gdb lagging behind the compiler
540*404b540aSrobert       (lack of personnel). We recommend configuring the compiler using
541*404b540aSrobert       --with-dwarf2 if the DWARF2 debugging format is not already the
542*404b540aSrobert       default on your platform. Also, [84]changing your GDB settings can
543*404b540aSrobert       have a profound effect on your C++ debugging experiences. :-)
544*404b540aSrobert     _________________________________________________________________
545*404b540aSrobert
546*404b540aSrobert4.3 Bugs in the C++ language/lib specification
547*404b540aSrobert
548*404b540aSrobert   Yes, unfortunately, there are some. In a [85]message to the list,
549*404b540aSrobert   Nathan Myers announced that he has started a list of problems in the
550*404b540aSrobert   ISO C++ Standard itself, especially with regard to the chapters that
551*404b540aSrobert   concern the library. The list itself is [86]posted on his website.
552*404b540aSrobert   Developers who are having problems interpreting the Standard may wish
553*404b540aSrobert   to consult his notes.
554*404b540aSrobert
555*404b540aSrobert   For those people who are not part of the ISO Library Group (i.e.,
556*404b540aSrobert   nearly all of us needing to read this page in the first place :-), a
557*404b540aSrobert   public list of the library defects is occasionally published [87]here.
558*404b540aSrobert   Some of these have resulted in [88]code changes.
559*404b540aSrobert     _________________________________________________________________
560*404b540aSrobert
561*404b540aSrobert4.4 Things in libstdc++ that only look like bugs
562*404b540aSrobert
563*404b540aSrobert   There are things which are not bugs in the compiler (4.2) nor the
564*404b540aSrobert   language specification (4.3), but aren't really bugs in libstdc++,
565*404b540aSrobert   either. Really! Please do not report these as bugs.
566*404b540aSrobert
567*404b540aSrobert   -Weffc++ The biggest of these is the quadzillions of warnings about
568*404b540aSrobert   the library headers emitted when -Weffc++ is used. Making libstdc++
569*404b540aSrobert   "-Weffc++-clean" is not a goal of the project, for a few reasons.
570*404b540aSrobert   Mainly, that option tries to enforce object-oriented programming,
571*404b540aSrobert   while the Standard Library isn't necessarily trying to be OO.
572*404b540aSrobert
573*404b540aSrobert   reopening a stream fails Did I just say that -Weffc++ was our biggest
574*404b540aSrobert   false-bug report? I lied. (It used to be.) Today it seems to be
575*404b540aSrobert   reports that after executing a sequence like
576*404b540aSrobert    #include <fstream>
577*404b540aSrobert    ...
578*404b540aSrobert    std::fstream  fs("a_file");
579*404b540aSrobert    // .
580*404b540aSrobert    // . do things with fs...
581*404b540aSrobert    // .
582*404b540aSrobert    fs.close();
583*404b540aSrobert    fs.open("a_new_file");
584*404b540aSrobert
585*404b540aSrobert   all operations on the re-opened fs will fail, or at least act very
586*404b540aSrobert   strangely. Yes, they often will, especially if fs reached the EOF
587*404b540aSrobert   state on the previous file. The reason is that the state flags are not
588*404b540aSrobert   cleared on a successful call to open(). The standard unfortunately did
589*404b540aSrobert   not specify behavior in this case, and to everybody's great sorrow,
590*404b540aSrobert   the [89]proposed LWG resolution in DR #22 is to leave the flags
591*404b540aSrobert   unchanged. You must insert a call to fs.clear() between the calls to
592*404b540aSrobert   close() and open(), and then everything will work like we all expect
593*404b540aSrobert   it to work. Update: for GCC 4.0 we implemented the resolution of
594*404b540aSrobert   [90]DR #409 and open() now calls clear() on success!
595*404b540aSrobert
596*404b540aSrobert   rel_ops Another is the rel_ops namespace and the template comparison
597*404b540aSrobert   operator functions contained therein. If they become visible in the
598*404b540aSrobert   same namespace as other comparison functions (e.g., 'using' them and
599*404b540aSrobert   the <iterator> header), then you will suddenly be faced with huge
600*404b540aSrobert   numbers of ambiguity errors. This was discussed on the -v3 list;
601*404b540aSrobert   Nathan Myers [91]sums things up here. The collisions with
602*404b540aSrobert   vector/string iterator types have been fixed for 3.1.
603*404b540aSrobert
604*404b540aSrobert  The g++-3 headers are not ours
605*404b540aSrobert
606*404b540aSrobert   If you have found an extremely broken header file which is causing
607*404b540aSrobert   problems for you, look carefully before submitting a "high" priority
608*404b540aSrobert   bug report (which you probably shouldn't do anyhow; see the last
609*404b540aSrobert   paragraph of the page describing [92]the GCC bug database).
610*404b540aSrobert
611*404b540aSrobert   If the headers are in ${prefix}/include/g++-3, or if the installed
612*404b540aSrobert   library's name looks like libstdc++-2.10.a or libstdc++-libc6-2.10.so,
613*404b540aSrobert   then you are using the old libstdc++-v2 library, which is nonstandard
614*404b540aSrobert   and unmaintained. Do not report problems with -v2 to the -v3 mailing
615*404b540aSrobert   list.
616*404b540aSrobert
617*404b540aSrobert   For GCC versions 3.0 and 3.1 the libstdc++-v3 header files are
618*404b540aSrobert   installed in ${prefix}/include/g++-v3 (see the 'v'?). Starting with
619*404b540aSrobert   version 3.2 the headers are installed in
620*404b540aSrobert   ${prefix}/include/c++/${version} as this prevents headers from
621*404b540aSrobert   previous versions being found by mistake.
622*404b540aSrobert
623*404b540aSrobert   glibc If you're on a GNU/Linux system and have just upgraded to glibc
624*404b540aSrobert   2.2, but are still using gcc 2.95.2, then you should have read the
625*404b540aSrobert   glibc FAQ, specifically 2.34:
626*404b540aSrobert2.34.   When compiling C++ programs, I get a compilation error in streambuf.h.
627*404b540aSrobert
628*404b540aSrobert{BH} You are using g++ 2.95.2? After upgrading to glibc 2.2, you need to
629*404b540aSrobertapply a patch to the include files in /usr/include/g++, because the fpos_t
630*404b540aSroberttype has changed in glibc 2.2.  The patch is at
631*404b540aSroberthttp://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
632*404b540aSrobert
633*404b540aSrobert
634*404b540aSrobert   Note that 2.95.x shipped with the [93]old v2 library which is no
635*404b540aSrobert   longer maintained. Also note that gcc 2.95.3 fixes this problem, but
636*404b540aSrobert   requires a separate patch for libstdc++-v3.
637*404b540aSrobert
638*404b540aSrobert   concept checks If you see compilation errors containing messages about
639*404b540aSrobert   fooConcept and a constraints member function, then most likely you
640*404b540aSrobert   have violated one of the requirements for types used during
641*404b540aSrobert   instantiation of template containers and functions. For example,
642*404b540aSrobert   EqualityComparableConcept appears if your types must be comparable
643*404b540aSrobert   with == and you have not provided this capability (a typo, or wrong
644*404b540aSrobert   visibility, or you just plain forgot, etc).
645*404b540aSrobert
646*404b540aSrobert   More information, including how to optionally enable/disable the
647*404b540aSrobert   checks, is available [94]here.
648*404b540aSrobert
649*404b540aSrobert   dlopen/dlsym If you are using the C++ library across
650*404b540aSrobert   dynamically-loaded objects, make certain that you are passing the
651*404b540aSrobert   correct options when compiling and linking:
652*404b540aSrobert    // compile your library components
653*404b540aSrobert    g++ -fPIC -c a.cc
654*404b540aSrobert    g++ -fPIC -c b.cc
655*404b540aSrobert    ...
656*404b540aSrobert    g++ -fPIC -c z.cc
657*404b540aSrobert
658*404b540aSrobert    // create your library
659*404b540aSrobert    g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o
660*404b540aSrobert
661*404b540aSrobert    // link the executable
662*404b540aSrobert    g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl
663*404b540aSrobert
664*404b540aSrobert   "memory leaks" in containers A few people have reported that the
665*404b540aSrobert   standard containers appear to leak memory when tested with memory
666*404b540aSrobert   checkers such as [95]valgrind. The library's default allocators keep
667*404b540aSrobert   free memory in a pool for later reuse, rather than returning it to the
668*404b540aSrobert   OS. Although this memory is always reachable by the library and is
669*404b540aSrobert   never lost, memory debugging tools can report it as a leak. If you
670*404b540aSrobert   want to test the library for memory leaks please read [96]Tips for
671*404b540aSrobert   memory leak hunting first.
672*404b540aSrobert     _________________________________________________________________
673*404b540aSrobert
674*404b540aSrobert4.5 Aw, that's easy to fix!
675*404b540aSrobert
676*404b540aSrobert   If you have found a bug in the library and you think you have a
677*404b540aSrobert   working fix, then send it in! The main GCC site has a page on
678*404b540aSrobert   [97]submitting patches that covers the procedure, but for libstdc++
679*404b540aSrobert   you should also send the patch to our mailing list in addition to the
680*404b540aSrobert   GCC patches mailing list. The libstdc++ [98]contributors' page also
681*404b540aSrobert   talks about how to submit patches.
682*404b540aSrobert
683*404b540aSrobert   In addition to the description, the patch, and the ChangeLog entry, it
684*404b540aSrobert   is a Good Thing if you can additionally create a small test program to
685*404b540aSrobert   test for the presence of the bug that your patch fixes. Bugs have a
686*404b540aSrobert   way of being reintroduced; if an old bug creeps back in, it will be
687*404b540aSrobert   caught immediately by the [99]testsuite -- but only if such a test
688*404b540aSrobert   exists.
689*404b540aSrobert     _________________________________________________________________
690*404b540aSrobert
691*404b540aSrobert                               5.0 Miscellaneous
692*404b540aSrobert
693*404b540aSrobert5.1 string::iterator is not char*; vector<T>::iterator is not T*
694*404b540aSrobert
695*404b540aSrobert   If you have code that depends on container<T> iterators being
696*404b540aSrobert   implemented as pointer-to-T, your code is broken.
697*404b540aSrobert
698*404b540aSrobert   While there are arguments for iterators to be implemented in that
699*404b540aSrobert   manner, A) they aren't very good ones in the long term, and B) they
700*404b540aSrobert   were never guaranteed by the Standard anyway. The type-safety achieved
701*404b540aSrobert   by making iterators a real class rather than a typedef for T*
702*404b540aSrobert   outweighs nearly all opposing arguments.
703*404b540aSrobert
704*404b540aSrobert   Code which does assume that a vector iterator i is a pointer can often
705*404b540aSrobert   be fixed by changing i in certain expressions to &*i . Future
706*404b540aSrobert   revisions of the Standard are expected to bless this usage for
707*404b540aSrobert   vector<> (but not for basic_string<>).
708*404b540aSrobert     _________________________________________________________________
709*404b540aSrobert
710*404b540aSrobert5.2 What's next after libstdc++-v3?
711*404b540aSrobert
712*404b540aSrobert   Hopefully, not much. The goal of libstdc++-v3 is to produce a
713*404b540aSrobert   fully-compliant, fully-portable Standard Library. After that, we're
714*404b540aSrobert   mostly done: there won't be any more compliance work to do. However:
715*404b540aSrobert    1. The ISO Committee will meet periodically to review Defect Reports
716*404b540aSrobert       in the C++ Standard. Undoubtedly some of these will result in
717*404b540aSrobert       changes to the Standard, which will be reflected in patches to
718*404b540aSrobert       libstdc++. Some of that is already happening, see [100]4.3. Some
719*404b540aSrobert       of those changes are being predicted by the library maintainers,
720*404b540aSrobert       and we add code to the library based on what the current proposed
721*404b540aSrobert       resolution specifies. Those additions are listed in [101]the
722*404b540aSrobert       extensions page.
723*404b540aSrobert    2. Performance tuning. Lots of performance tuning. This too is
724*404b540aSrobert       already underway for post-3.0 releases, starting with memory
725*404b540aSrobert       expansion in container classes and buffer usage in synchronized
726*404b540aSrobert       stream objects.
727*404b540aSrobert    3. An ABI for libstdc++ is being developed, so that multiple
728*404b540aSrobert       binary-incompatible copies of the library can be replaced with a
729*404b540aSrobert       single backwards-compatible library, like libgcc_s.so is.
730*404b540aSrobert    4. The current libstdc++ contains extensions to the Library which
731*404b540aSrobert       must be explicitly requested by client code (for example, the hash
732*404b540aSrobert       tables from SGI). Other extensions may be added to libstdc++-v3 if
733*404b540aSrobert       they seem to be "standard" enough. (For example, the "long long"
734*404b540aSrobert       type from C99.) Bugfixes and rewrites (to improve or fix thread
735*404b540aSrobert       safety, for instance) will of course be a continuing task.
736*404b540aSrobert    5. There is an effort underway to add significant extensions to the
737*404b540aSrobert       standard library specification. The latest version of this effort
738*404b540aSrobert       is described in [102]The C++ Library Technical Report 1. See
739*404b540aSrobert       [103]5.5.
740*404b540aSrobert
741*404b540aSrobert   [104]This question about the next libstdc++ prompted some brief but
742*404b540aSrobert   interesting [105]speculation.
743*404b540aSrobert     _________________________________________________________________
744*404b540aSrobert
745*404b540aSrobert5.3 What about the STL from SGI?
746*404b540aSrobert
747*404b540aSrobert   The [106]STL from SGI, version 3.3, was the final merge of the STL
748*404b540aSrobert   codebase. The code in libstdc++ contains many fixes and changes, and
749*404b540aSrobert   the SGI code is no longer under active development. We expect that no
750*404b540aSrobert   future merges will take place.
751*404b540aSrobert
752*404b540aSrobert   In particular, string is not from SGI and makes no use of their "rope"
753*404b540aSrobert   class (which is included as an optional extension), nor is valarray
754*404b540aSrobert   and some others. Classes like vector<> are, however we have made
755*404b540aSrobert   significant changes to them since then.
756*404b540aSrobert
757*404b540aSrobert   The FAQ for SGI's STL (one jump off of their main page) is recommended
758*404b540aSrobert   reading.
759*404b540aSrobert     _________________________________________________________________
760*404b540aSrobert
761*404b540aSrobert5.4 Extensions and Backward Compatibility
762*404b540aSrobert
763*404b540aSrobert   Headers in the ext and backward subdirectories should be referred to
764*404b540aSrobert   by their relative paths:
765*404b540aSrobert      #include <ext/hash_map>
766*404b540aSrobert
767*404b540aSrobert   rather than using -I or other options. This is more portable and
768*404b540aSrobert   forward-compatible. (The situation is the same as that of other
769*404b540aSrobert   headers whose directories are not searched directly, e.g.,
770*404b540aSrobert   <sys/stat.h>, <X11/Xlib.h>.
771*404b540aSrobert
772*404b540aSrobert   At this time most of the features of the SGI STL extension have been
773*404b540aSrobert   replaced by standardized libraries. In particular, the unordered_map
774*404b540aSrobert   and unordered_set containers of TR1 are suitable replacement for the
775*404b540aSrobert   non-standard hash_map and hash_set containers in the SGI STL. See
776*404b540aSrobert   [107]5.5 for more details.
777*404b540aSrobert
778*404b540aSrobert   The extensions are no longer in the global or std namespaces, instead
779*404b540aSrobert   they are declared in the __gnu_cxx namespace. For maximum portability,
780*404b540aSrobert   consider defining a namespace alias to use to talk about extensions,
781*404b540aSrobert   e.g.:
782*404b540aSrobert      #ifdef __GNUC__
783*404b540aSrobert      #if __GNUC__ < 3
784*404b540aSrobert        #include <hash_map.h>
785*404b540aSrobert        namespace Sgi { using ::hash_map; }; // inherit globals
786*404b540aSrobert      #else
787*404b540aSrobert        #include <ext/hash_map>
788*404b540aSrobert        #if __GNUC_MINOR__ == 0
789*404b540aSrobert          namespace Sgi = std;               // GCC 3.0
790*404b540aSrobert        #else
791*404b540aSrobert          namespace Sgi = ::__gnu_cxx;       // GCC 3.1 and later
792*404b540aSrobert        #endif
793*404b540aSrobert      #endif
794*404b540aSrobert      #else      // ...  there are other compilers, right?
795*404b540aSrobert        namespace Sgi = std;
796*404b540aSrobert      #endif
797*404b540aSrobert
798*404b540aSrobert      Sgi::hash_map<int,int> my_map;
799*404b540aSrobert
800*404b540aSrobert   This is a bit cleaner than defining typedefs for all the
801*404b540aSrobert   instantiations you might need.
802*404b540aSrobert
803*404b540aSrobert   Note: explicit template specializations must be declared in the same
804*404b540aSrobert   namespace as the original template. This means you cannot use a
805*404b540aSrobert   namespace alias when declaring an explicit specialization.
806*404b540aSrobert
807*404b540aSrobert   Extensions to the library have [108]their own page.
808*404b540aSrobert     _________________________________________________________________
809*404b540aSrobert
810*404b540aSrobert5.5 Does libstdc++ support TR1?
811*404b540aSrobert
812*404b540aSrobert   The C++ Standard Library Technical Report adds many new features to
813*404b540aSrobert   the library. The latest version of this effort is described in
814*404b540aSrobert   [109]Technical Report 1.
815*404b540aSrobert
816*404b540aSrobert   libstdc++ strives to implement all of TR1. An [110]overview of the
817*404b540aSrobert   implementation status is available.
818*404b540aSrobert
819*404b540aSrobert   Briefly, the features of TR1 and the current status are:
820*404b540aSrobert
821*404b540aSrobert   Reference_wrapper - Complete - Useful to pass references to functions
822*404b540aSrobert   that take their parameters by value.
823*404b540aSrobert
824*404b540aSrobert   Reference-counted smart pointers - Complete - The shared_ptr and
825*404b540aSrobert   weak_ptr allow several object to know about a pointer and whether it
826*404b540aSrobert   is valid. When the last reference to the pointer is destroyed the
827*404b540aSrobert   pointer is freed.
828*404b540aSrobert
829*404b540aSrobert   Function objects - Complete - Function return types (i.e, result_of),
830*404b540aSrobert   the functions template mem_fn (a generalization of mem_fun and
831*404b540aSrobert   mem_fun_red), function object binders (e.g, bind, a generalization of
832*404b540aSrobert   bind1st and bind2nd), and polymorhpic function wrappers (e.g, class
833*404b540aSrobert   template function).
834*404b540aSrobert
835*404b540aSrobert   Type traits - Complete - The type_traits class gives templates the
836*404b540aSrobert   ability to probe information about the input type and enable
837*404b540aSrobert   type-dependent logic to be performed without the need of template
838*404b540aSrobert   specializations.
839*404b540aSrobert
840*404b540aSrobert   A random number engine - Complete - This library contains randow
841*404b540aSrobert   number generators with several different choices of distribution.
842*404b540aSrobert
843*404b540aSrobert   Tuples - Complete - The tuple class implements small heterogeneous
844*404b540aSrobert   arrays. This is an enhanced pair. In fact, the standard pair is
845*404b540aSrobert   enhanced with a tuple interface.
846*404b540aSrobert
847*404b540aSrobert   Fixed-size arrays - Complete - The array class implements small
848*404b540aSrobert   fixed-sized arrays with container semantics.
849*404b540aSrobert
850*404b540aSrobert   Unordered containers - Complete - The unordered_set, unordered_map,
851*404b540aSrobert   unordered_multiset, and unordered_multimap containers are hashed
852*404b540aSrobert   versions of the map, set, multimap, and multiset containers
853*404b540aSrobert   respectively. These classes are suitable replacements for the SGI STL
854*404b540aSrobert   hash_map and hash_set extensions.
855*404b540aSrobert
856*404b540aSrobert   C99 compatibility - Under construction - There are many features
857*404b540aSrobert   designed to minimize the divergence of the C and the C++ languages.
858*404b540aSrobert
859*404b540aSrobert   Special functions - Under construction - Twenty-three mathematical
860*404b540aSrobert   functions familiar to physicists and engineers are included:
861*404b540aSrobert   cylindrical and spherical Bessel and Neumann functions, hypergeometric
862*404b540aSrobert   functions, Laguerre polynomials, Legendre functions, elliptic
863*404b540aSrobert   integrals, exponential integrals and the Riemann zeta function all for
864*404b540aSrobert   your computing pleasure.
865*404b540aSrobert
866*404b540aSrobert   A regular expression engine This library provides for regular
867*404b540aSrobert   expression objects with traversal of text with return of
868*404b540aSrobert   subexpressions.
869*404b540aSrobert     _________________________________________________________________
870*404b540aSrobert
871*404b540aSrobert5.6 Is libstdc++-v3 thread-safe?
872*404b540aSrobert
873*404b540aSrobert   libstdc++-v3 strives to be thread-safe when all of the following
874*404b540aSrobert   conditions are met:
875*404b540aSrobert     * The system's libc is itself thread-safe,
876*404b540aSrobert     * gcc -v reports a thread model other than 'single',
877*404b540aSrobert     * [pre-3.3 only] a non-generic implementation of atomicity.h exists
878*404b540aSrobert       for the architecture in question.
879*404b540aSrobert
880*404b540aSrobert   The user-code must guard against concurrent method calls which may
881*404b540aSrobert   access any particular library object's state. Typically, the
882*404b540aSrobert   application programmer may infer what object locks must be held based
883*404b540aSrobert   on the objects referenced in a method call. Without getting into great
884*404b540aSrobert   detail, here is an example which requires user-level locks:
885*404b540aSrobert     library_class_a shared_object_a;
886*404b540aSrobert
887*404b540aSrobert     thread_main () {
888*404b540aSrobert       library_class_b *object_b = new library_class_b;
889*404b540aSrobert       shared_object_a.add_b (object_b);   // must hold lock for shared_object_
890*404b540aSroberta
891*404b540aSrobert       shared_object_a.mutate ();          // must hold lock for shared_object_
892*404b540aSroberta
893*404b540aSrobert     }
894*404b540aSrobert
895*404b540aSrobert     // Multiple copies of thread_main() are started in independent threads.
896*404b540aSrobert
897*404b540aSrobert   Under the assumption that object_a and object_b are never exposed to
898*404b540aSrobert   another thread, here is an example that should not require any
899*404b540aSrobert   user-level locks:
900*404b540aSrobert     thread_main () {
901*404b540aSrobert       library_class_a object_a;
902*404b540aSrobert       library_class_b *object_b = new library_class_b;
903*404b540aSrobert       object_a.add_b (object_b);
904*404b540aSrobert       object_a.mutate ();
905*404b540aSrobert     }
906*404b540aSrobert
907*404b540aSrobert   All library objects are safe to use in a multithreaded program as long
908*404b540aSrobert   as each thread carefully locks out access by any other thread while it
909*404b540aSrobert   uses any object visible to another thread, i.e., treat library objects
910*404b540aSrobert   like any other shared resource. In general, this requirement includes
911*404b540aSrobert   both read and write access to objects; unless otherwise documented as
912*404b540aSrobert   safe, do not assume that two threads may access a shared standard
913*404b540aSrobert   library object at the same time.
914*404b540aSrobert
915*404b540aSrobert   See chapters [111]17 (library introduction), [112]23 (containers), and
916*404b540aSrobert   [113]27 (I/O) for more information.
917*404b540aSrobert     _________________________________________________________________
918*404b540aSrobert
919*404b540aSrobert5.7 How do I get a copy of the ISO C++ Standard?
920*404b540aSrobert
921*404b540aSrobert   Copies of the full ISO 14882 standard are available on line via the
922*404b540aSrobert   ISO mirror site for committee members. Non-members, or those who have
923*404b540aSrobert   not paid for the privilege of sitting on the committee and sustained
924*404b540aSrobert   their two-meeting commitment for voting rights, may get a copy of the
925*404b540aSrobert   standard from their respective national standards organization. In the
926*404b540aSrobert   USA, this national standards organization is ANSI and their website is
927*404b540aSrobert   right [114]here. (And if you've already registered with them, clicking
928*404b540aSrobert   this link will take you to directly to the place where you can
929*404b540aSrobert   [115]buy the standard on-line.
930*404b540aSrobert
931*404b540aSrobert   Who is your country's member body? Visit the [116]ISO homepage and
932*404b540aSrobert   find out!
933*404b540aSrobert     _________________________________________________________________
934*404b540aSrobert
935*404b540aSrobert5.8 What's an ABI and why is it so messy?
936*404b540aSrobert
937*404b540aSrobert   "ABI" stands for "Application Binary Interface." Conventionally, it
938*404b540aSrobert   refers to a great mass of details about how arguments are arranged on
939*404b540aSrobert   the call stack and/or in registers, and how various types are arranged
940*404b540aSrobert   and padded in structs. A single CPU design may suffer multiple ABIs
941*404b540aSrobert   designed by different development tool vendors who made different
942*404b540aSrobert   choices, or even by the same vendor for different target applications
943*404b540aSrobert   or compiler versions. In ideal circumstances the CPU designer presents
944*404b540aSrobert   one ABI and all the OSes and compilers use it. In practice every ABI
945*404b540aSrobert   omits details that compiler implementers (consciously or accidentally)
946*404b540aSrobert   must choose for themselves.
947*404b540aSrobert
948*404b540aSrobert   That ABI definition suffices for compilers to generate code so a
949*404b540aSrobert   program can interact safely with an OS and its lowest-level libraries.
950*404b540aSrobert   Users usually want an ABI to encompass more detail, allowing libraries
951*404b540aSrobert   built with different compilers (or different releases of the same
952*404b540aSrobert   compiler!) to be linked together. For C++, this includes many more
953*404b540aSrobert   details than for C, and CPU designers (for good reasons elaborated
954*404b540aSrobert   below) have not stepped up to publish C++ ABIs. The details include
955*404b540aSrobert   virtual function implementation, struct inheritance layout, name
956*404b540aSrobert   mangling, and exception handling. Such an ABI has been defined for GNU
957*404b540aSrobert   C++, and is immediately useful for embedded work relying only on a
958*404b540aSrobert   "free-standing implementation" that doesn't include (much of) the
959*404b540aSrobert   standard library. It is a good basis for the work to come.
960*404b540aSrobert
961*404b540aSrobert   A useful C++ ABI must also incorporate many details of the standard
962*404b540aSrobert   library implementation. For a C ABI, the layouts of a few structs
963*404b540aSrobert   (such as FILE, stat, jmpbuf, and the like) and a few macros suffice.
964*404b540aSrobert   For C++, the details include the complete set of names of functions
965*404b540aSrobert   and types used, the offsets of class members and virtual functions,
966*404b540aSrobert   and the actual definitions of all inlines. C++ exposes many more
967*404b540aSrobert   library details to the caller than C does. It makes defining a
968*404b540aSrobert   complete ABI a much bigger undertaking, and requires not just
969*404b540aSrobert   documenting library implementation details, but carefully designing
970*404b540aSrobert   those details so that future bug fixes and optimizations don't force
971*404b540aSrobert   breaking the ABI.
972*404b540aSrobert
973*404b540aSrobert   There are ways to help isolate library implementation details from the
974*404b540aSrobert   ABI, but they trade off against speed. Library details used in inner
975*404b540aSrobert   loops (e.g., getchar) must be exposed and frozen for all time, but
976*404b540aSrobert   many others may reasonably be kept hidden from user code, so they may
977*404b540aSrobert   later be changed. Deciding which, and implementing the decisions, must
978*404b540aSrobert   happen before you can reasonably document a candidate C++ ABI that
979*404b540aSrobert   encompasses the standard library.
980*404b540aSrobert     _________________________________________________________________
981*404b540aSrobert
982*404b540aSrobert5.9 How do I make std::vector<T>::capacity() == std::vector<T>::size()?
983*404b540aSrobert
984*404b540aSrobert   The standard idiom for deallocating a std::vector<T>'s unused memory
985*404b540aSrobert   is to create a temporary copy of the vector and swap their contents,
986*404b540aSrobert   e.g. for std::vector<T> v
987*404b540aSrobert     std::vector<T>(v).swap(v);
988*404b540aSrobert
989*404b540aSrobert
990*404b540aSrobert   The copy will take O(n) time and the swap is constant time.
991*404b540aSrobert
992*404b540aSrobert   See [117]Shrink-to-fit strings for a similar solution for strings.
993*404b540aSrobert     _________________________________________________________________
994*404b540aSrobert
995*404b540aSrobert   See [118]license.html for copying conditions. Comments and suggestions
996*404b540aSrobert   are welcome, and may be sent to [119]the libstdc++ mailing list.
997*404b540aSrobert
998*404b540aSrobertReferences
999*404b540aSrobert
1000*404b540aSrobert   1. ../documentation.html
1001*404b540aSrobert   2. ../17_intro/license.html
1002*404b540aSrobert   3. http://gcc.gnu.org/onlinedocs/libstdc++/faq/
1003*404b540aSrobert   4. http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html
1004*404b540aSrobert   5. http://gcc.gnu.org/libstdc++/
1005*404b540aSrobert   6. ../faq/index.html#1_0
1006*404b540aSrobert   7. ../faq/index.html#1_1
1007*404b540aSrobert   8. ../faq/index.html#1_2
1008*404b540aSrobert   9. ../faq/index.html#1_3
1009*404b540aSrobert  10. ../faq/index.html#1_4
1010*404b540aSrobert  11. ../faq/index.html#1_5
1011*404b540aSrobert  12. ../faq/index.html#1_6
1012*404b540aSrobert  13. ../faq/index.html#1_7
1013*404b540aSrobert  14. ../faq/index.html#1_8
1014*404b540aSrobert  15. ../faq/index.html#1_9
1015*404b540aSrobert  16. ../faq/index.html#2_0
1016*404b540aSrobert  17. ../faq/index.html#2_1
1017*404b540aSrobert  18. ../faq/index.html#2_2
1018*404b540aSrobert  19. ../faq/index.html#2_3
1019*404b540aSrobert  20. ../faq/index.html#2_4
1020*404b540aSrobert  21. ../faq/index.html#2_5
1021*404b540aSrobert  22. ../faq/index.html#2_6
1022*404b540aSrobert  23. ../faq/index.html#3_0
1023*404b540aSrobert  24. ../faq/index.html#3_1
1024*404b540aSrobert  25. ../faq/index.html#3_2
1025*404b540aSrobert  26. ../faq/index.html#3_3
1026*404b540aSrobert  27. ../faq/index.html#3_4
1027*404b540aSrobert  28. ../faq/index.html#3_5
1028*404b540aSrobert  29. ../faq/index.html#3_6
1029*404b540aSrobert  30. ../faq/index.html#3_7
1030*404b540aSrobert  31. ../faq/index.html#3_8
1031*404b540aSrobert  32. ../faq/index.html#3_9
1032*404b540aSrobert  33. ../faq/index.html#3_10
1033*404b540aSrobert  34. ../faq/index.html#4_0
1034*404b540aSrobert  35. ../faq/index.html#4_1
1035*404b540aSrobert  36. ../faq/index.html#4_2
1036*404b540aSrobert  37. ../faq/index.html#4_3
1037*404b540aSrobert  38. ../faq/index.html#4_4
1038*404b540aSrobert  39. ../faq/index.html#4_4_iostreamclear
1039*404b540aSrobert  40. ../faq/index.html#4_4_Weff
1040*404b540aSrobert  41. ../faq/index.html#4_4_rel_ops
1041*404b540aSrobert  42. ../faq/index.html#4_4_interface
1042*404b540aSrobert  43. ../faq/index.html#4_4_glibc
1043*404b540aSrobert  44. ../faq/index.html#4_4_checks
1044*404b540aSrobert  45. ../faq/index.html#4_4_dlsym
1045*404b540aSrobert  46. ../faq/index.html#4_4_leak
1046*404b540aSrobert  47. ../faq/index.html#4_5
1047*404b540aSrobert  48. ../faq/index.html#5_0
1048*404b540aSrobert  49. ../faq/index.html#5_1
1049*404b540aSrobert  50. ../faq/index.html#5_2
1050*404b540aSrobert  51. ../faq/index.html#5_3
1051*404b540aSrobert  52. ../faq/index.html#5_4
1052*404b540aSrobert  53. ../faq/index.html#5_5
1053*404b540aSrobert  54. ../faq/index.html#5_6
1054*404b540aSrobert  55. ../faq/index.html#5_7
1055*404b540aSrobert  56. ../faq/index.html#5_8
1056*404b540aSrobert  57. ../faq/index.html#5_9
1057*404b540aSrobert  58. ../faq/index.html#1_4
1058*404b540aSrobert  59. ../faq/index.html#4_4_interface
1059*404b540aSrobert  60. ../17_intro/DESIGN
1060*404b540aSrobert  61. http://gcc.gnu.org/
1061*404b540aSrobert  62. http://gcc.gnu.org/gcc-3.3/buildstat.html
1062*404b540aSrobert  63. http://gcc.gnu.org/libstdc++/
1063*404b540aSrobert  64. http://gcc.gnu.org/libstdc++/
1064*404b540aSrobert  65. http://gcc.gnu.org/releases.html
1065*404b540aSrobert  66. ../17_intro/contribute.html
1066*404b540aSrobert  67. http://www.boost.org/
1067*404b540aSrobert  68. http://gcc.gnu.org/extensions.html
1068*404b540aSrobert  69. mailto:libstdc++@gcc.gnu.org
1069*404b540aSrobert  70. mailto:pme@gcc.gnu.org
1070*404b540aSrobert  71. mailto:gdr@gcc.gnu.org
1071*404b540aSrobert  72. ../17_intro/license.html
1072*404b540aSrobert  73. ../documentation.html
1073*404b540aSrobert  74. ../17_intro/RELEASE-NOTES
1074*404b540aSrobert  75. http://subversion.tigris.org/
1075*404b540aSrobert  76. http://gcc.gnu.org/install/test.html
1076*404b540aSrobert  77. ../18_support/howto.html
1077*404b540aSrobert  78. http://gcc.gnu.org/cgi-bin/htsearch?method=and&format=builtin-long&sort=score&words=_XOPEN_SOURCE+Solaris
1078*404b540aSrobert  79. http://gcc.gnu.org/ml/gcc/2002-03/msg00817.html
1079*404b540aSrobert  80. http://gcc.gnu.org/ml/libstdc++/2003-02/subjects.html#00286
1080*404b540aSrobert  81. http://gcc.gnu.org/install/configure.html
1081*404b540aSrobert  82. http://gcc.gnu.org/install/
1082*404b540aSrobert  83. http://gcc.gnu.org/bugs.html
1083*404b540aSrobert  84. http://gcc.gnu.org/ml/libstdc++/2002-02/msg00034.html
1084*404b540aSrobert  85. http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html
1085*404b540aSrobert  86. http://www.cantrip.org/draft-bugs.txt
1086*404b540aSrobert  87. http://anubis.dkuug.dk/jtc1/sc22/wg21/
1087*404b540aSrobert  88. ../faq/index.html#5_2
1088*404b540aSrobert  89. ../ext/howto.html#5
1089*404b540aSrobert  90. ../ext/howto.html#5
1090*404b540aSrobert  91. http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html
1091*404b540aSrobert  92. http://gcc.gnu.org/bugs.html
1092*404b540aSrobert  93. ../faq/index.html#4_4_interface
1093*404b540aSrobert  94. ../19_diagnostics/howto.html#3
1094*404b540aSrobert  95. http://developer.kde.org/~sewardj/
1095*404b540aSrobert  96. ../debug.html#mem
1096*404b540aSrobert  97. http://gcc.gnu.org/contribute.html
1097*404b540aSrobert  98. ../17_intro/contribute.html
1098*404b540aSrobert  99. ../faq/index.html#2_4
1099*404b540aSrobert 100. ../faq/index.html#4_3
1100*404b540aSrobert 101. ../ext/howto.html#5
1101*404b540aSrobert 102. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
1102*404b540aSrobert 103. ../faq/index.html#5_5
1103*404b540aSrobert 104. http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html
1104*404b540aSrobert 105. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html
1105*404b540aSrobert 106. http://www.sgi.com/tech/stl/
1106*404b540aSrobert 107. ../faq/index.html#5_5
1107*404b540aSrobert 108. ../ext/howto.html
1108*404b540aSrobert 109. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
1109*404b540aSrobert 110. ../ext/tr1.html
1110*404b540aSrobert 111. ../17_intro/howto.html#3
1111*404b540aSrobert 112. ../23_containers/howto.html#3
1112*404b540aSrobert 113. ../27_io/howto.html#9
1113*404b540aSrobert 114. http://www.ansi.org/
1114*404b540aSrobert 115. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%3A2003
1115*404b540aSrobert 116. http://www.iso.ch/
1116*404b540aSrobert 117. ../21_strings/howto.html#6
1117*404b540aSrobert 118. ../17_intro/license.html
1118*404b540aSrobert 119. mailto:libstdc++@gcc.gnu.org
1119