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