OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [doc/] [xml/] [faq.xml] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
2
3
 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
4
[ ]>
5
 
6
7
 
8
9
10
 
11
12
  Frequently Asked Questions
13
  
14
    
15
      2008
16
    
17
    
18
      FSF
19
    
20
  
21
22
 
23
24
25
 
26
27
28
General Information
29
 
30
31
  
32
    
33
      What is libstdc++?
34
    
35
  
36
  
37
    
38
     The GNU Standard C++ Library v3 is an ongoing project to
39
     implement the ISO 14882 Standard C++ library as described in
40
     chapters 17 through 27 and annex D.  For those who want to see
41
     exactly how far the project has come, or just want the latest
42
     bleeding-edge code, the up-to-date source is available over
43
     anonymous SVN, and can even be browsed over
44
     the web.
45
    
46
  
47
48
 
49
50
  
51
    
52
      Why should I use libstdc++?
53
    
54
  
55
  
56
    
57
    The completion of the ISO C++ standardization gave the C++
58
    community a powerful set of reuseable tools in the form of the C++
59
    Standard Library.  However, all existing C++ implementations are
60
    (as the Draft Standard used to say) incomplet and
61
    incorrekt, and many suffer from limitations of the compilers
62
    that use them.
63
    
64
    
65
    The GNU compiler collection
66
    (gcc, g++, etc) is widely
67
    considered to be one of the leading compilers in the world.  Its
68
    development is overseen by the
69
    GCC team.  All of
70
    the rapid development and near-legendary
71
    portability
72
    that are the hallmarks of an open-source project are being
73
    applied to libstdc++.
74
    
75
    
76
    That means that all of the Standard classes and functions will be
77
    freely available and fully compliant. (Such as
78
    string,
79
    vector<>, iostreams, and algorithms.)
80
    Programmers will no longer need to roll their own
81
    nor be worried about platform-specific incompatibilities.
82
    
83
  
84
85
 
86
87
  
88
    
89
      Who's in charge of it?
90
    
91
  
92
  
93
    
94
     The libstdc++ project is contributed to by several developers
95
     all over the world, in the same way as GCC or Linux.
96
     Benjamin Kosnik, Gabriel Dos Reis, Phil Edwards, Ulrich Drepper,
97
     Loren James Rittle, and Paolo Carlini are the lead maintainers of
98
     the SVN archive.
99
    
100
    
101
    Development and discussion is held on the libstdc++ mailing
102
    list.  Subscribing to the list, or searching the list
103
    archives, is open to everyone.  You can read instructions for
104
    doing so on the homepage.
105
    If you have questions, ideas, code, or are just curious, sign up!
106
    
107
  
108
109
 
110
111
  
112
    
113
      When is libstdc++ going to be finished?
114
    
115
  
116
  
117
    
118
    Nathan Myers gave the best of all possible answers, responding to
119
    a Usenet article asking this question: Sooner, if you
120
    help.
121
    
122
  
123
124
 
125
126
  
127
    
128
      How do I contribute to the effort?
129
    
130
  
131
  
132
    
133
    Here is a page devoted to
134
    this topic. Subscribing to the mailing list (see above, or
135
    the homepage) is a very good idea if you have something to
136
    contribute, or if you have spare time and want to
137
    help. Contributions don't have to be in the form of source code;
138
    anybody who is willing to help write documentation, for example,
139
    or has found a bug in code that we all thought was working and is
140
    willing to provide details, is more than welcome!
141
    
142
  
143
144
 
145
146
  
147
    
148
      What happened to the older libg++? I need that!
149
    
150
  
151
  
152
    
153
    The most recent libg++ README states that libg++ is no longer
154
    being actively maintained.  It should not be used for new
155
    projects, and is only being kicked along to support older code.
156
    
157
    
158
    More information in the backwards compatibility documentation
159
    
160
  
161
162
 
163
164
  
165
    
166
      What if I have more questions?
167
    
168
  
169
  
170
    
171
    If you have read the README file, and your question remains
172
    unanswered, then just ask the mailing list. At present, you do not
173
    need to be subscribed to the list to send a message to it.  More
174
    information is available on the homepage (including how to browse
175
    the list archives); to send a message to the list,
176
    use libstdc++@gcc.gnu.org.
177
    
178
 
179
    
180
    If you have a question that you think should be included
181
    here, or if you have a question about a question/answer
182
    here, please send email to the libstdc++ mailing list, as above.
183
    
184
  
185
186
 
187
188
 
189
190
191
License
192
 
193
194
  
195
    
196
      What are the license terms for libstdc++?
197
    
198
  
199
  
200
    
201
    See our license description
202
    for these and related questions.
203
    
204
  
205
206
 
207
208
  
209
    
210
      So any program which uses libstdc++ falls under the GPL?
211
    
212
  
213
  
214
    
215
     No. The special exception permits use of the library in
216
     proprietary applications.
217
    
218
  
219
220
 
221
 
222
223
  
224
    
225
      How is that different from the GNU {Lesser,Library} GPL?
226
    
227
  
228
  
229
    
230
      The LGPL requires that users be able to replace the LGPL code with a
231
     modified version; this is trivial if the library in question is a C
232
     shared library.  But there's no way to make that work with C++, where
233
     much of the library consists of inline functions and templates, which
234
     are expanded inside the code that uses the library.  So to allow people
235
     to replace the library code, someone using the library would have to
236
     distribute their own source, rendering the LGPL equivalent to the GPL.
237
    
238
  
239
240
 
241
242
  
243
    
244
      I see. So, what restrictions are there on programs that use the library?
245
    
246
  
247
  
248
    
249
      None.  We encourage such programs to be released as open source,
250
     but we won't punish you or sue you if you choose otherwise.
251
    
252
  
253
254
 
255
256
 
257
258
259
Installation
260
 
261
262
  
263
    How do I install libstdc++?
264
    
265
  
266
  
267
    
268
    Often libstdc++ comes pre-installed as an integral part of many
269
    existing Linux and Unix systems, as well as many embedded
270
    development tools. It may be necessary to install extra
271
    development packages to get the headers, or the documentation, or
272
    the source: please consult your vendor for details.
273
    
274
    
275
    To build and install from the GNU GCC sources, please consult the
276
    setup
277
    documentation for detailed
278
    instructions. You may wish to browse those files ahead
279
    of time to get a feel for what's required.
280
    
281
  
282
283
 
284
285
  
286
    How does one get current libstdc++ sources?
287
    
288
  
289
  
290
    
291
    Libstdc++ sources for all official releases can be obtained as
292
    part of the GCC sources, available from various sites and
293
    mirrors. A full list of
294
    download sites is provided on the main GCC site.
295
    
296
    
297
    Current libstdc++ sources can always be checked out of the main
298
    GCC source repository using the appropriate version control
299
    tool. At this time, that tool
300
    is Subversion.
301
    
302
    
303
    Subversion, or SVN, is
304
    one of several revision control packages.  It was selected for GNU
305
    projects because it's free (speech), free (beer), and very high
306
    quality.  The  Subversion
307
    home page has a better description.
308
    
309
    
310
    The anonymous client checkout feature of SVN is
311
    similar to anonymous FTP in that it allows anyone to retrieve
312
    the latest libstdc++ sources.
313
    
314
    
315
    For more information
316
    see SVN
317
    details.
318
    
319
  
320
321
 
322
323
  
324
    How do I know if it works?
325
    
326
  
327
  
328
    
329
    Libstdc++ comes with its own validation testsuite, which includes
330
    conformance testing, regression testing, ABI testing, and
331
    performance testing. Please consult the
332
    testing
333
    documentation for more details.
334
    
335
    
336
    If you find bugs in the testsuite programs themselves, or if you
337
    think of a new test program that should be added to the suite,
338
    please write up your idea and send it to the list!
339
    
340
  
341
342
 
343
344
  
345
    How do I insure that the dynamically linked library will be found?
346
    
347
  
348
  
349
    
350
    Depending on your platform and library version, the error message might
351
    be similar to one of the following:
352
    
353
 
354
    
355
    ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
356
 
357
    /usr/libexec/ld-elf.so.1: Shared object "libstdc++.so.6" not found
358
    
359
 
360
    
361
    This doesn't mean that the shared library isn't installed, only
362
    that the dynamic linker can't find it. When a dynamically-linked
363
    executable is run the linker finds and loads the required shared
364
    libraries by searching a pre-configured list of directories. If
365
    the directory where you've installed libstdc++ is not in this list
366
    then the libraries won't be found. The simplest way to fix this is
367
    to use the LD_LIBRARY_PATH environment variable,
368
    which is a colon-separated list of directories in which the linker
369
    will search for shared libraries:
370
    
371
 
372
    
373
    LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH
374
    export LD_LIBRARY_PATH
375
    
376
 
377
    
378
    The exact environment variable to use will depend on your
379
    platform, e.g. DYLD_LIBRARY_PATH for Darwin,
380
    LD_LIBRARY_PATH_32/LD_LIBRARY_PATH_64 for Solaris 32-/64-bit,
381
    LD_LIBRARYN32_PATH/LD_LIBRARY64_PATH for Irix N32/64-bit ABIs and
382
    SHLIB_PATH for HP-UX.
383
    
384
    
385
    See the man pages for ld, ldd
386
    and ldconfig for more information. The dynamic
387
    linker has different names on different platforms but the man page
388
    is usually called something such as ld.so/rtld/dld.so.
389
    
390
  
391
392
 
393
394
  
395
    
396
      What's libsupc++?
397
    
398
  
399
  
400
    
401
      If the only functions from libstdc++.a
402
      which you need are language support functions (those listed in
403
      clause 18 of the
404
      standard, e.g., new and
405
      delete), then try linking against
406
      libsupc++.a, which is a subset of
407
      libstdc++.a.  (Using gcc
408
      instead of g++ and explicitly linking in
409
      libsupc++.a via -lsupc++
410
      for the final link step will do it).  This library contains only
411
      those support routines, one per object file.  But if you are
412
      using anything from the rest of the library, such as IOStreams
413
      or vectors, then you'll still need pieces from
414
      libstdc++.a.
415
    
416
  
417
418
 
419
420
  
421
    
422
      This library is HUGE!
423
    
424
  
425
  
426
    
427
    Usually the size of libraries on disk isn't noticeable.  When a
428
    link editor (or simply linker) pulls things from a
429
    static archive library, only the necessary object files are copied
430
    into your executable, not the entire library.  Unfortunately, even
431
    if you only need a single function or variable from an object file,
432
    the entire object file is extracted.  (There's nothing unique to C++
433
    or libstdc++ about this; it's just common behavior, given here
434
    for background reasons.)
435
    
436
    
437
    Some of the object files which make up libstdc++.a are rather large.
438
    If you create a statically-linked executable with
439
    -static, those large object files are suddenly part
440
    of your executable.  Historically the best way around this was to
441
    only place a very few functions (often only a single one) in each
442
    source/object file; then extracting a single function is the same
443
    as extracting a single .o file.  For libstdc++ this is only
444
    possible to a certain extent; the object files in question contain
445
    template classes and template functions, pre-instantiated, and
446
    splitting those up causes severe maintenance headaches.
447
    
448
    
449
    On supported platforms, libstdc++ takes advantage of garbage
450
    collection in the GNU linker to get a result similar to separating
451
    each symbol into a separate source and object files. On these platforms,
452
    GNU ld can place each function and variable into its own
453
    section in a .o file.  The GNU linker can then perform garbage
454
    collection on unused sections; this reduces the situation to only
455
    copying needed functions into the executable, as before, but all
456
    happens automatically.
457
    
458
  
459
460
 
461
462
 
463
 
464
465
466
Platform-Specific Issues
467
 
468
469
  
470
    
471
      Can libstdc++ be used with non-GNU compilers?
472
    
473
  
474
  
475
    
476
    Perhaps.
477
    
478
    
479
    Since the goal of ISO Standardization is for all C++
480
    implementations to be able to share code, libstdc++ should be
481
    usable under any ISO-compliant compiler, at least in theory.
482
    
483
    
484
    However, the reality is that libstdc++ is targeted and optimized
485
    for GCC/g++. This means that often libstdc++ uses specific,
486
    non-standard features of g++ that are not present in older
487
    versions of proprietary compilers. It may take as much as a year or two
488
    after an official release of GCC that contains these features for
489
    proprietary tools support these constructs.
490
    
491
    
492
    In the near past, specific released versions of libstdc++ have
493
    been known to work with versions of the EDG C++ compiler, and
494
    vendor-specific proprietary C++ compilers such as the Intel ICC
495
    C++ compiler.
496
    
497
 
498
  
499
500
 
501
502
  
503
    
504
      No 'long long' type on Solaris?
505
    
506
  
507
  
508
    
509
    By default we try to support the C99 long long type.
510
    This requires that certain functions from your C library be present.
511
    
512
    
513
    Up through release 3.0.2 the platform-specific tests performed by
514
    libstdc++ were too general, resulting in a conservative approach
515
    to enabling the long long code paths. The most
516
    commonly reported platform affected was Solaris.
517
    
518
    
519
    This has been fixed for libstdc++ releases greater than 3.0.3.
520
    
521
  
522
523
 
524
525
  
526
    
527
      _XOPEN_SOURCE and _GNU_SOURCE are always defined?
528
    
529
  
530
  
531
      On Solaris, g++ (but not gcc) always defines the preprocessor
532
         macro _XOPEN_SOURCE.  On GNU/Linux, the same happens
533
         with _GNU_SOURCE.  (This is not an exhaustive list;
534
         other macros and other platforms are also affected.)
535
      
536
      These macros are typically used in C library headers, guarding new
537
         versions of functions from their older versions.  The C++ standard
538
         library includes the C standard library, but it requires the C90
539
         version, which for backwards-compatibility reasons is often not the
540
         default for many vendors.
541
      
542
      More to the point, the C++ standard requires behavior which is only
543
         available on certain platforms after certain symbols are defined.
544
         Usually the issue involves I/O-related typedefs.  In order to
545
         ensure correctness, the compiler simply predefines those symbols.
546
      
547
      Note that it's not enough to #define them only when the library is
548
         being built (during installation).  Since we don't have an 'export'
549
         keyword, much of the library exists as headers, which means that
550
         the symbols must also be defined as your programs are parsed and
551
         compiled.
552
      
553
      To see which symbols are defined, look for CPLUSPLUS_CPP_SPEC in
554
         the gcc config headers for your target (and try changing them to
555
         see what happens when building complicated code).  You can also run
556
         g++ -E -dM - < /dev/null" to display
557
         a list of predefined macros for any particular installation.
558
      
559
      This has been discussed on the mailing lists
560
         quite a bit.
561
      
562
      This method is something of a wart.  We'd like to find a cleaner
563
         solution, but nobody yet has contributed the time.
564
      
565
 
566
  
567
568
 
569
570
  
571
    
572
      Mac OS X ctype.h is broken! How can I fix it?
573
    
574
  
575
  
576
      This is a long-standing bug in the OS X support.  Fortunately,
577
         the patch is quite simple, and well-known.
578
          Here's a
579
         link to the solution.
580
      
581
 
582
  
583
584
 
585
586
  
587
    
588
      Threading is broken on i386?
589
    
590
  
591
  
592
    
593
    
594
      Support for atomic integer operations is/was broken on i386
595
         platforms.  The assembly code accidentally used opcodes that are
596
         only available on the i486 and later.  So if you configured GCC
597
         to target, for example, i386-linux, but actually used the programs
598
         on an i686, then you would encounter no problems.  Only when
599
         actually running the code on a i386 will the problem appear.
600
      
601
      This is fixed in 3.2.2.
602
      
603
 
604
  
605
606
 
607
608
  
609
    
610
      MIPS atomic operations
611
    
612
  
613
  
614
    
615
    The atomic locking routines for MIPS targets requires MIPS II
616
    and later.  A patch went in just after the 3.3 release to
617
    make mips* use the generic implementation instead.  You can also
618
    configure for mipsel-elf as a workaround.
619
    
620
    
621
    The mips*-*-linux* port continues to use the MIPS II routines, and more
622
    work in this area is expected.
623
    
624
  
625
626
 
627
628
  
629
    
630
      Recent GNU/Linux glibc required?
631
    
632
  
633
  
634
      When running on GNU/Linux, libstdc++ 3.2.1 (shared library version
635
         5.0.1) and later uses localization and formatting code from the system
636
         C library (glibc) version 2.2.5.  That version of glibc is over a
637
         year old and contains necessary bugfixes.  Many GNU/Linux distros make
638
         glibc version 2.3.x available now.
639
      
640
      The guideline is simple:  the more recent the C++ library, the
641
         more recent the C library.  (This is also documented in the main
642
         GCC installation instructions.)
643
      
644
 
645
  
646
647
 
648
649
  
650
    
651
      Can't use wchar_t/wstring on FreeBSD
652
    
653
  
654
  
655
    
656
    Older versions of FreeBSD's C library do not have sufficient
657
    support for wide character functions, and as a result the
658
    libstdc++ configury decides that wchar_t support should be
659
    disabled. In addition, the libstdc++ platform checks that
660
    enabled wchar_t were quite strict, and not granular
661
    enough to detect when the minimal support to
662
    enable wchar_t and C++ library structures
663
    like wstring were present. This impacted Solaris,
664
    Darwin, and BSD variants, and is fixed in libstdc++ versions post 4.1.0.
665
    
666
    
667
    
668
  
669
670
 
671
672
 
673
 
674
675
676
Known Bugs
677
 
678
679
  
680
    
681
      What works already?
682
    
683
  
684
  
685
    
686
    Short answer: Pretty much everything works
687
    except for some corner cases.  Support for localization
688
    in locale may be incomplete on non-GNU
689
    platforms. Also dependant on the underlying platform is support
690
    for wchar_t and long
691
    long specializations, and details of thread support.
692
    
693
    
694
    Long answer: See the implementation status pages for
695
    C++98,
696
    TR1, and
697
    C++0x.
698
    
699
  
700
701
 
702
703
  
704
    
705
      Bugs in the ISO C++ language or library specification
706
    
707
  
708
  
709
    
710
    Unfortunately, there are some.
711
    
712
    
713
    For those people who are not part of the ISO Library Group
714
    (i.e., nearly all of us needing to read this page in the first
715
    place), a public list of the library defects is occasionally
716
    published here.
717
    Some of these issues have resulted in code changes in libstdc++.
718
    
719
    
720
    If you think you've discovered a new bug that is not listed,
721
    please post a message describing your problem
722
    to libstdc++@gcc.gnu.org or the Usenet group
723
    comp.lang.c++.moderated.
724
    
725
  
726
727
 
728
729
  
730
    
731
      Bugs in the compiler (gcc/g++) and not libstdc++
732
    
733
  
734
  
735
    
736
    On occasion, the compiler is wrong. Please be advised that this
737
    happens much less often than one would think, and avoid jumping to
738
    conclusions.
739
    
740
    
741
    First, examine the ISO C++ standard. Second, try another compiler
742
    or an older version of the GNU compilers. Third, you can find more
743
    information on the libstdc++ and the GCC mailing lists: search
744
    these lists with terms describing your issue.
745
    
746
    
747
    Before reporting a bug, please examine the
748
    bugs database with the
749
    category set to g++.
750
    
751
  
752
753
 
754
755
 
756
757
758
Known Non-Bugs
759
 
760
761
  
762
    
763
      Reopening a stream fails
764
    
765
  
766
  
767
    
768
    One of the most-reported non-bug reports. Executing a sequence like:
769
    
770
 
771
    
772
    #include <fstream>
773
    ...
774
    std::fstream  fs(a_file);
775
    // .
776
    // . do things with fs...
777
    // .
778
    fs.close();
779
    fs.open(a_new_file);
780
    
781
 
782
    
783
    All operations on the re-opened fs will fail, or at
784
    least act very strangely.  Yes, they often will, especially if
785
    fs reached the EOF state on the previous file.  The
786
    reason is that the state flags are not cleared
787
    on a successful call to open().  The standard unfortunately did
788
    not specify behavior in this case, and to everybody's great sorrow,
789
    the proposed LWG resolution in
790
      DR #22 is to leave the flags unchanged.  You must insert a call
791
    to fs.clear() between the calls to close() and open(),
792
    and then everything will work like we all expect it to work.
793
    Update: for GCC 4.0 we implemented the resolution
794
    of DR #409 and open()
795
    now calls clear() on success!
796
    
797
  
798
799
 
800
801
  
802
    
803
      -Weffc++ complains too much
804
    
805
  
806
  
807
    
808
    Many warnings are emitted when -Weffc++ is used.  Making
809
    libstdc++ -Weffc++-clean is not a goal of the project,
810
    for a few reasons.  Mainly, that option tries to enforce
811
    object-oriented programming, while the Standard Library isn't
812
    necessarily trying to be OO.
813
    
814
    
815
    We do, however, try to have libstdc++ sources as clean as possible. If
816
    you see some simple changes that pacify -Weffc++
817
    without other drawbacks, send us a patch.
818
    
819
  
820
821
 
822
823
  
824
    
825
      Ambiguous overloads after including an old-style header
826
    
827
  
828
  
829
    
830
    Another problem is the rel_ops namespace and the template
831
    comparison operator functions contained therein.  If they become
832
    visible in the same namespace as other comparison functions
833
    (e.g., using them and the <iterator> header),
834
    then you will suddenly be faced with huge numbers of ambiguity
835
    errors.  This was discussed on the -v3 list; Nathan Myers
836
    sums
837
      things up here.  The collisions with vector/string iterator
838
    types have been fixed for 3.1.
839
    
840
  
841
842
 
843
844
  
845
    
846
      The g++-3 headers are not ours
847
    
848
  
849
  
850
      
851
        If you have found an extremely broken header file which is
852
        causing problems for you, look carefully before submitting a
853
        "high" priority bug report (which you probably
854
        shouldn't do anyhow; see the last paragraph of the page
855
        describing the GCC
856
        bug database).
857
      
858
      
859
        If the headers are in ${prefix}/include/g++-3, or
860
        if the installed library's name looks like
861
        libstdc++-2.10.a or
862
        libstdc++-libc6-2.10.so, then you are using the
863
        old libstdc++-v2 library, which is nonstandard and
864
        unmaintained.  Do not report problems with -v2 to the -v3
865
        mailing list.
866
      
867
      
868
        For GCC versions 3.0 and 3.1 the libstdc++ header files are
869
        installed in ${prefix}/include/g++-v3 (see the
870
        'v'?).  Starting with version 3.2 the headers are installed in
871
        ${prefix}/include/c++/${version} as this prevents
872
        headers from previous versions being found by mistake.
873
      
874
 
875
  
876
877
 
878
879
  
880
    
881
      Errors about *Concept and
882
      constraints in the STL
883
    
884
  
885
  
886
    
887
    If you see compilation errors containing messages about
888
    foo Concept and something to do with a
889
    constraints member function, then most
890
    likely you have violated one of the requirements for types used
891
    during instantiation of template containers and functions.  For
892
    example, EqualityComparableConcept appears if your types must be
893
    comparable with == and you have not provided this capability (a
894
    typo, or wrong visibility, or you just plain forgot, etc).
895
    
896
    
897
    More information, including how to optionally enable/disable the
898
    checks, is available
899
    here.
900
    
901
  
902
903
 
904
905
  
906
    
907
      Program crashes when using library code in a
908
      dynamically-loaded library
909
    
910
  
911
  
912
    
913
    If you are using the C++ library across dynamically-loaded
914
    objects, make certain that you are passing the correct options
915
    when compiling and linking:
916
    
917
 
918
    
919
    // compile your library components
920
    g++ -fPIC -c a.cc
921
    g++ -fPIC -c b.cc
922
    ...
923
    g++ -fPIC -c z.cc
924
 
925
    // create your library
926
    g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o
927
 
928
    // link the executable
929
    g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl
930
    
931
  
932
933
 
934
935
  
936
    
937
      Memory leaks in containers
938
    
939
  
940
  
941
    
942
    A few people have reported that the standard containers appear
943
    to leak memory when tested with memory checkers such as
944
    valgrind.
945
    The library's default allocators keep free memory in a pool
946
    for later reuse, rather than returning it to the OS.  Although
947
    this memory is always reachable by the library and is never
948
    lost, memory debugging tools can report it as a leak.  If you
949
    want to test the library for memory leaks please read
950
    Tips for memory leak hunting
951
    first.
952
    
953
  
954
955
 
956
957
  
958
    
959
      list::size() is O(n)!
960
    
961
  
962
  
963
    
964
    See
965
    the Containers
966
    chapter.
967
    
968
  
969
970
 
971
972
  
973
    
974
      Aw, that's easy to fix!
975
    
976
  
977
  
978
    
979
    If you have found a bug in the library and you think you have
980
    a working fix, then send it in!  The main GCC site has a page
981
    on submitting
982
    patches that covers the procedure, but for libstdc++ you
983
    should also send the patch to our mailing list in addition to
984
    the GCC patches mailing list.  The libstdc++
985
    contributors' page
986
    also talks about how to submit patches.
987
    
988
    
989
    In addition to the description, the patch, and the ChangeLog
990
    entry, it is a Good Thing if you can additionally create a small
991
    test program to test for the presence of the bug that your
992
    patch fixes.  Bugs have a way of being reintroduced; if an old
993
    bug creeps back in, it will be caught immediately by the
994
    testsuite -- but only if such a test exists.
995
    
996
  
997
998
 
999
1000
 
1001
 
1002
1003
1004
Miscellaneous
1005
 
1006
1007
  
1008
    
1009
      string::iterator is not char*; vector<T>::iterator is not T*
1010
    
1011
  
1012
  
1013
    
1014
    If you have code that depends on container<T> iterators
1015
    being implemented as pointer-to-T, your code is broken. It's
1016
    considered a feature, not a bug, that libstdc++ points this out.
1017
    
1018
    
1019
    While there are arguments for iterators to be implemented in
1020
    that manner, A) they aren't very good ones in the long term,
1021
    and B) they were never guaranteed by the Standard anyway.  The
1022
    type-safety achieved by making iterators a real class rather
1023
    than a typedef for T* outweighs nearly all opposing
1024
    arguments.
1025
    
1026
    
1027
    Code which does assume that a vector iterator i
1028
    is a pointer can often be fixed by changing i in
1029
    certain expressions to &*i.  Future revisions
1030
    of the Standard are expected to bless this usage for
1031
    vector<> (but not for basic_string<>).
1032
    
1033
  
1034
1035
 
1036
1037
  
1038
    
1039
      What's next after libstdc++?
1040
    
1041
  
1042
  
1043
      
1044
        Hopefully, not much.  The goal of libstdc++ is to produce a
1045
        fully-compliant, fully-portable Standard Library.  After that,
1046
        we're mostly done: there won't be any
1047
        more compliance work to do.
1048
      
1049
      
1050
        There is an effort underway to add significant extensions to
1051
        the standard library specification.  The latest version of
1052
        this effort is described in
1053
         
1054
         The C++ Library Technical Report 1.
1055
      
1056
  
1057
1058
 
1059
1060
  
1061
    
1062
      What about the STL from SGI?
1063
    
1064
  
1065
  
1066
    
1067
      The STL from SGI,
1068
    version 3.3, was the final merge of the STL codebase.  The
1069
    code in libstdc++ contains many fixes and changes, and
1070
    the SGI code is no longer under active
1071
    development.  We expect that no future merges will take place.
1072
    
1073
    
1074
    In particular, string is not from SGI and makes no
1075
    use of their "rope" class (which is included as an
1076
    optional extension), nor is valarray and some others.
1077
    Classes like vector<> are, but have been
1078
    extensively modified.
1079
    
1080
    
1081
    More information on the evolution of libstdc++ can be found at the
1082
    API
1083
    evolution
1084
    and backwards
1085
    compatibility documentation.
1086
    
1087
    
1088
    The FAQ for SGI's STL (one jump off of their main page) is
1089
    still recommended reading.
1090
    
1091
  
1092
1093
 
1094
1095
  
1096
    
1097
      Extensions and Backward Compatibility
1098
    
1099
  
1100
  
1101
    
1102
      See the link on backwards compatibility and link on evolution.
1103
    
1104
  
1105
1106
 
1107
1108
  
1109
    
1110
      Does libstdc++ support TR1?
1111
    
1112
  
1113
  
1114
    
1115
    Yes.
1116
    
1117
    
1118
    The C++ Standard Library Technical Report adds many new features to
1119
    the library.  The latest version of this effort is described in
1120
    
1121
         "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">
1122
         Technical Report 1.
1123
    
1124
    
1125
    The implementation status of TR1 in libstdc++ can be tracked 
1126
    linkend="status.iso.tr1">on the TR1 status
1127
    page.
1128
    
1129
  
1130
1131
 
1132
1133
  
1134
    How do I get a copy of the ISO C++ Standard?
1135
    
1136
  
1137
  
1138
    
1139
    Copies of the full ISO 14882 standard are available on line via
1140
    the ISO mirror site for committee members.  Non-members, or those
1141
    who have not paid for the privilege of sitting on the committee
1142
    and sustained their two-meeting commitment for voting rights, may
1143
    get a copy of the standard from their respective national
1144
    standards organization.  In the USA, this national standards
1145
    organization is ANSI and their website is
1146
    right here.  (And if
1147
    you've already registered with them, clicking this link will take
1148
    you to directly to the place where you can
1149
    buy the standard on-line.
1150
    
1151
    
1152
    Who is your country's member body?  Visit the
1153
    ISO homepage and find out!
1154
    
1155
    
1156
    The 2003 version of the standard (the 1998 version plus TC1) is
1157
    available in print, ISBN 0-470-84674-7.
1158
    
1159
  
1160
1161
 
1162
1163
  
1164
    
1165
      What's an ABI and why is it so messy?
1166
    
1167
  
1168
  
1169
    
1170
    ABI stands for Application Binary
1171
     Interface.  Conventionally, it refers to a great
1172
    mass of details about how arguments are arranged on the call
1173
    stack and/or in registers, and how various types are arranged
1174
    and padded in structs.  A single CPU design may suffer
1175
    multiple ABIs designed by different development tool vendors
1176
    who made different choices, or even by the same vendor for
1177
    different target applications or compiler versions.  In ideal
1178
    circumstances the CPU designer presents one ABI and all the
1179
    OSes and compilers use it.  In practice every ABI omits
1180
    details that compiler implementers (consciously or
1181
    accidentally) must choose for themselves.
1182
    
1183
    
1184
    That ABI definition suffices for compilers to generate code so a
1185
    program can interact safely with an OS and its lowest-level libraries.
1186
    Users usually want an ABI to encompass more detail, allowing libraries
1187
    built with different compilers (or different releases of the same
1188
    compiler!) to be linked together.  For C++, this includes many more
1189
    details than for C, and CPU designers (for good reasons elaborated
1190
    below) have not stepped up to publish C++ ABIs.  The details include
1191
    virtual function implementation, struct inheritance layout, name
1192
    mangling, and exception handling.  Such an ABI has been defined for
1193
    GNU C++, and is immediately useful for embedded work relying only on
1194
    a free-standing implementation that doesn't include (much
1195
    of) the standard library.  It is a good basis for the work to come.
1196
    
1197
    
1198
    A useful C++ ABI must also incorporate many details of the standard
1199
    library implementation.  For a C ABI, the layouts of a few structs
1200
    (such as FILE, stat, jmpbuf, and the like) and a few macros suffice.
1201
    For C++, the details include the complete set of names of functions
1202
    and types used, the offsets of class members and virtual functions,
1203
    and the actual definitions of all inlines.  C++ exposes many more
1204
    library details to the caller than C does.  It makes defining
1205
    a complete ABI a much bigger undertaking, and requires not just
1206
    documenting library implementation details, but carefully designing
1207
    those details so that future bug fixes and optimizations don't
1208
    force breaking the ABI.
1209
    
1210
    
1211
    There are ways to help isolate library implementation details from the
1212
    ABI, but they trade off against speed.  Library details used in
1213
    inner loops (e.g., getchar) must be exposed and frozen for all
1214
    time, but many others may reasonably be kept hidden from user code,
1215
    so they may later be changed.  Deciding which, and implementing
1216
    the decisions, must happen before you can reasonably document a
1217
    candidate C++ ABI that encompasses the standard library.
1218
    
1219
  
1220
1221
 
1222
1223
  
1224
    
1225
      How do I make std::vector<T>::capacity() == std::vector<T>::size?
1226
    
1227
  
1228
  
1229
    
1230
    The standard idiom for deallocating a vector<T>'s
1231
    unused memory is to create a temporary copy of the vector and swap their
1232
    contents, e.g. for vector<T> v
1233
    
1234
    
1235
     std::vector<T>(v).swap(v);
1236
    
1237
    
1238
    The copy will take O(n) time and the swap is constant time.
1239
    
1240
    
1241
    See Shrink-to-fit
1242
    strings for a similar solution for strings.
1243
    
1244
  
1245
1246
 
1247
1248
 
1249
 
1250
1251
1252
 
1253
1254
 
1255

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.