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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [doc/] [xml/] [faq.xml] - Blame information for rev 748

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

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

powered by: WebSVN 2.1.0

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