summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/docs/html/17_intro/howto.html
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/docs/html/17_intro/howto.html')
-rw-r--r--libstdc++-v3/docs/html/17_intro/howto.html599
1 files changed, 397 insertions, 202 deletions
diff --git a/libstdc++-v3/docs/html/17_intro/howto.html b/libstdc++-v3/docs/html/17_intro/howto.html
index d3bd6dfe393..3e1bba08acb 100644
--- a/libstdc++-v3/docs/html/17_intro/howto.html
+++ b/libstdc++-v3/docs/html/17_intro/howto.html
@@ -34,123 +34,309 @@
<hr />
<h1>Contents</h1>
<ul>
- <li><a href="#2.1">Header Files</a></li>
- <li><a href="#5">Implementation specific behavior</a></li>
+ <li><a href="#2.0">Header Files</a></li>
+ <li><a href="#3.0">Namespaces</a></li>
<li><a href="#6">Macros</a></li>
- <li><a href="#3">Multithreading</a></li>
+ <li><a href="#5">Implementation specific behavior</a></li>
+ <li><a href="#7">Multithreading</a></li>
</ul>
<hr />
<!-- ####################################################### -->
-<h2><a name="2.1">Header Files</a></h2>
- <p>The C++ standard specifies 50 header files that must be
+<h2><a name="2.0">Header Files</a></h2>
+ <p>The C++ standard specifies the entire set of header files that must be
available to all hosted implementations. Actually, the word
&quot;files&quot; is a misnomer, since the contents of the headers
don't necessarily have to be in any kind of external file. The
- only rule is that when one <code>#include</code>'s a certain header, the
- contents of that header, as defined by the Standard, become
+ only rule is that when one <code>#include</code>'s a header, the
+ contents of that header become
available, no matter how.
</p>
-<p>C++98/03 include files:
+<p>That said, in practice files are used.</p>
+
+<p> There are two main types of include files: header files related to
+a specific version of the ISO C++ standard (called Standard Headers),
+and all others (TR1, C++ ABI, and Extensions).</p>
+
+<p>Two dialects of standard headers are supported, corresponding to
+the 1998 standard as updated for 2003, and the draft of the upcoming
+200x standard.
+</p>
+
+<p>C++98/03 include files. These are available in the default compilation mode, ie <code>-std=c++98</code> or <code>-std=gnu++98</code>.
</p>
-<pre>
-C++ Library Headers
-algorithm ios new stack
-bitset iosfwd numeric stdexcept
-complex iostream ostream streambuf
- istream queue string
-deque iterator
-exception limits typeinfo
-fstream list set
-functional locale map
-iomanip memory sstream
-
-C++ Headers for C Library Facilities
-cassert cfloat cmath cstddef
-ccomplex csetjmp cstdio ctime
-cctype ciso646 csignal
-cerrno climits cstdarg cstdlib cwchar
- clocale cstring cwctype
-</pre>
-<p>C++0x include files:
+<center><table border="1"><caption>C++98 Library Headers</caption>
+<tr><td>&lt;algorithm&gt;</td><td>&lt;iomanip&gt;</td><td>&lt;list&gt;</td><td>&lt;ostream&gt;</td><td>&lt;streambuf&gt;</td></tr>
+<tr><td>&lt;bitset&gt;</td><td>&lt;ios&gt;</td><td>&lt;locale&gt;</td><td>&lt;queue&gt;</td><td>&lt;string&gt;</td></tr>
+<tr><td>&lt;complex&gt;</td><td>&lt;iosfwd&gt;</td><td>&lt;map&gt;</td><td>&lt;set&gt;</td><td>&lt;typeinfo&gt;</td></tr>
+<tr><td>&lt;deque&gt;</td><td>&lt;iostream&gt;</td><td>&lt;memory&gt;</td><td>&lt;sstream&gt;</td><td>&lt;utility&gt;</td></tr>
+<tr><td>&lt;exception&gt;</td><td>&lt;istream&gt;</td><td>&lt;new&gt;</td><td>&lt;stack&gt;</td><td>&lt;valarray&gt;</td></tr>
+<tr><td>&lt;fstream&gt;</td><td>&lt;iterator&gt;</td><td>&lt;numeric&gt;</td><td>&lt;stdexcept&gt;</td><td>&lt;vector&gt;</td></tr>
+<tr><td>&lt;functional&gt;</td><td>&lt;limits&gt;</td></tr>
+</table></center>
+
+<p></p>
+
+<center><table border="1"><caption>C++98 Headers for C Library Facilities</caption>
+<tr><td>&lt;cassert&gt;</td><td>&lt;ciso646&gt;</td><td>&lt;csetjmp&gt;</td><td>&lt;cstdio&gt;</td><td>&lt;ctime&gt;</td></tr>
+<tr><td>&lt;cctype&gt;</td><td>&lt;climits&gt;</td><td>&lt;csignal&gt;</td><td>&lt;cstdlib&gt;</td><td>&lt;cwchar&gt;</td></tr>
+<tr><td>&lt;cerrno&gt;</td><td>&lt;clocale&gt;</td><td>&lt;cstdarg&gt;</td><td>&lt;cstring&gt;</td><td>&lt;cwctype&gt;</td></tr>
+<tr><td>&lt;cfloat&gt;</td><td>&lt;cmath&gt;</td><td>&lt;cstddef&gt;</td></tr>
+</table></center>
+
+<p>C++0x include files. These are only available in C++0x compilation mode, ie <code>-std=c++0x</code> or <code>-std=gnu++0x</code>.
</p>
+
+<center><table border="1"><caption>C++0x Library Headers</caption>
+<tr><td>&lt;algorithm&gt;</td><td>&lt;iomanip&gt;</td><td>&lt;locale&gt;</td><td>&lt;regex&gt;</td><td>&lt;tuple&gt;</td></tr>
+<tr><td>&lt;array&gt;</td><td>&lt;ios&gt;</td><td>&lt;map&gt;</td><td>&lt;set&gt;</td><td>&lt;typeinfo&gt;</td></tr>
+<tr><td>&lt;bitset&gt;</td><td>&lt;iosfwd&gt;</td><td>&lt;memory&gt;</td><td>&lt;sstream&gt;</td><td>&lt;type_traits&gt;</td></tr>
+<tr><td>&lt;complex&gt;</td><td>&lt;iostream&gt;</td><td>&lt;new&gt;</td><td>&lt;stack&gt;</td><td>&lt;unordered_map&gt;</td></tr>
+<tr><td>&lt;deque&gt;</td><td>&lt;istream&gt;</td><td>&lt;numeric&gt;</td><td>&lt;stdexcept&gt;</td><td>&lt;unordered_set&gt;</td></tr>
+<tr><td>&lt;exception&gt;</td><td>&lt;iterator&gt;</td><td>&lt;ostream&gt;</td><td>&lt;streambuf&gt;</td><td>&lt;utility&gt;</td></tr>
+<tr><td>&lt;fstream&gt;</td><td>&lt;limits&gt;</td><td>&lt;queue&gt;</td><td>&lt;string&gt;</td><td>&lt;valarray&gt;</td></tr>
+<tr><td>&lt;functional&gt;</td><td>&lt;list&gt;</td><td>&lt;random&gt;</td><td>&lt;system_error&gt;</td><td>&lt;vector&gt;</td></tr>
+</table></center>
+
+<p></p>
+
+<center><table border="1"><caption>C++0x Headers for C Library Facilities</caption>
+<tr><td>&lt;cassert&gt;</td><td>&lt;cfloat&gt;</td><td>&lt;cmath&gt;</td><td>&lt;cstddef&gt;</td><td>&lt;ctgmath&gt;</td></tr>
+<tr><td>&lt;ccomplex&gt;</td><td>&lt;cinttypes&gt;</td><td>&lt;csetjmp&gt;</td><td>&lt;cstdint&gt;</td><td>&lt;ctime&gt;</td></tr>
+<tr><td>&lt;cctype&gt;</td><td>&lt;ciso646&gt;</td><td>&lt;csignal&gt;</td><td>&lt;cstdio&gt;</td><td>&lt;cuchar&gt;</td></tr>
+<tr><td>&lt;cerrno&gt;</td><td>&lt;climits&gt;</td><td>&lt;cstdarg&gt;</td><td>&lt;cstdlib&gt;</td><td>&lt;cwchar&gt;</td></tr>
+<tr><td>&lt;cfenv&gt;</td><td>&lt;clocale&gt;</td><td>&lt;cstdbool&gt;</td><td>&lt;cstring&gt;</td><td>&lt;cwctype&gt;</td></tr>
+</table></center>
+
+
+<p>In addition, TR1 includes as:
+</p>
+
+<center><table border="1"><caption>TR1 Library Headers</caption>
+<tr><td>&lt;tr1/array&gt;</td><td>&lt;tr1/memory&gt;</td><td>&lt;tr1/regex&gt;</td><td>&lt;tr1/type_traits&gt;</td><td>&lt;tr1/unordered_set&gt;</td></tr>
+<tr><td>&lt;tr1/complex&gt;</td><td>&lt;tr1/random&gt;</td><td>&lt;tr1/tuple&gt;</td><td>&lt;tr1/unordered_map&gt;</td><td>&lt;tr1/utility&gt;</td></tr>
+<tr><td>&lt;tr1/functional&gt;</td></tr>
+</table></center>
+
+<p></p>
+
+<center><table border="1"><caption>TR1 Headers for C Library Facilities</caption>
+<tr><td>&lt;tr1/cmath&gt;</td><td>&lt;tr1/cfloat&gt;</td><td>&lt;tr1/cstdarg&gt;</td><td>&lt;tr1/cstdio&gt;</td><td>&lt;tr1/ctime&gt;</td></tr>
+<tr><td>&lt;tr1/ccomplex&gt;</td><td>&lt;tr1/cinttypes&gt;</td><td>&lt;tr1/cstdbool&gt;</td><td>&lt;tr1/cstdlib&gt;</td><td>&lt;tr1/cwchar&gt;</td></tr>
+<tr><td>&lt;tr1/cfenv&gt;</td><td>&lt;tr1/climits&gt;</td><td>&lt;tr1/cstdint&gt;</td><td>&lt;tr1/ctgmath&gt;</td><td>&lt;tr1/cwctype&gt;<td></tr>
+</table></center>
+
+<p>Also included are files for the C++ ABI interface:
+</p>
+<center><table border="1"><caption>C++ ABI Headers</caption>
+<tr><td>&lt;cxxabi.h&gt;</td><td>&lt;cxxabi_forced.h&gt;</td></tr>
+</table></center>
+
+<p>And a large variety of extensions.
+</p>
+
+<center><table border="1"><caption>Extension Headers</caption>
+<tr><td>&lt;ext/algorithm&gt;</td><td>&lt;ext/debug_allocator.h&gt;</td><td>&lt;ext/mt_allocator.h&gt;</td><td>&lt;ext/pod_char_traits.h&gt;</td><td>&lt;ext/stdio_sync_filebuf.h&gt;</td></tr>
+<tr><td>&lt;ext/array_allocator.h&gt;</td><td>&lt;ext/enc_filebuf.h&gt;</td><td>&lt;ext/new_allocator.h&gt;</td><td>&lt;ext/pool_allocator.h&gt;</td><td>&lt;ext/throw_allocator.h&gt;</td></tr>
+<tr><td>&lt;ext/atomicity.h&gt;</td><td>&lt;ext/functional&gt;</td><td>&lt;ext/numeric&gt;</td><td>&lt;ext/rb_tree&gt;</td><td>&lt;ext/typelist.h&gt;<td></tr>
+<tr><td>&lt;ext/bitmap_allocator.h&gt;</td><td>&lt;ext/iterator&gt;</td><td>&lt;ext/numeric_traits.h&gt;</td><td>&lt;ext/rope&gt;</td><td>&lt;ext/type_traits.h&gt;</td></tr>
+<tr><td>&lt;ext/codecvt_specializations.h&gt;</td><td>&lt;ext/malloc_allocator.h&gt;</td><td>&lt;ext/pb_ds/assoc_container.h&gt;</td><td>&lt;ext/slist&gt;</td><td>&lt;ext/vstring.h&gt;</td></tr>
+<tr><td>&lt;ext/concurrence.h&gt;</td><td>&lt;ext/memory&gt;</td><td>&lt;ext/pb_ds/priority_queue.h&gt;</td><td>&lt;ext/stdio_filebuf.h&gt;</td></tr>
+</table></center>
+
+<p></p>
+
+<center><table border="1"><caption>Extension Debug Headers</caption>
+<tr><td>&lt;debug/bitset&gt;</td><td>&lt;debug/list&gt;</td><td>&lt;debug/set&gt;</td><td>&lt;debug/unordered_map&gt;</td><td>&lt;debug/vector&gt;</td></tr>
+<tr><td>&lt;debug/deque&gt;</td><td>&lt;debug/map&gt;</td><td>&lt;debug/string&gt;</td><td>&lt;debug/unordered_set&gt;</td></tr>
+</table></center>
+
+<p></p>
+
+<center><table border="1"><caption>Extension Parallel Headers</caption>
+<tr><td>&lt;parallel/algorithm&gt;</td><td>&lt;parallel/numeric&gt;</td></tr>
+</table></center>
+
+<hr />
+<h2><a name="2.1">Recipes for mixing headers</code></a></h2>
+
+<p> A few simple rules.
+</p>
+
+<p>First, mixing different dialects of the standard headers is not
+possible. It's an all-or-nothing affair. Thus, code like
+</p>
+
<pre>
-C++ Library Headers
-algorithm ios new stack
-array iosfwd numeric stdexcept
-bitset iostream ostream streambuf
-complex istream queue string
-deque iterator random system_error
-exception limits regex tuple
-fstream list set type_traits
-functional locale map typeinfo
-iomanip memory sstream
-
-C++ Headers for C Library Facilities
-cassert cfloat cmath cstddef ctgmath
-ccomplex cinttypes csetjmp cstdio ctime
-cctype ciso646 csignal cstdint cuchar
-cerrno climits cstdarg cstdlib cwchar
-cfenv clocale cstdbool cstring cwctype
+#include &lt;array&gt;
+#include &lt;functional&gt;
</pre>
-<p>In addition, TR1 includes as:
+<p>Implies C++0x mode. To use the entities in &lt;array&gt;, the C++0x
+compilation mode must be used, which implies the C++0x functionality
+(and deprecations) in &lt;functional&gt; will be present.
+</p>
+
+<p>Second, the other headers can be included with either dialect of
+the standard headers, although features and types specific to C++0x
+are still only enabled when in C++0x compilation mode. So, to use
+rvalue references with <code>__gnu_cxx::vstring</code>, or to use the
+debug-mode versions of <code>std::unordered_map</code>, one must use
+the <code>std=gnu++0x</code> compiler flag. (Or <code>std=c++0x</code>, of course.)
</p>
+
+<p>A special case of the second rule is the mixing of TR1 and C++0x
+facilities. It is possible (although not especially prudent) to
+include both the TR1 version and the C++0x version of header in the
+same translation unit:
+</p>
+
<pre>
-C++ Library Headers
-tr1/array, tr1/complex, tr1/functional, tr1/memory, tr1/random,
-tr1/regex, tr1/tuple, tr1/type_traits, tr1/unordered_map,
-tr1/unordered_set, tr1/utility
-
-C++ Headers for C Library Facilities
-tr1/cmath, tr1/ccomplex, tr1/cfenv, tr1/cfloat, tr1/cinttypes,
-tr1/climits, tr1/cstdarg, tr1/cstdbool, tr1/cstdint, tr1/cstdio,
-tr1/cstdlib, tr1/ctgmath, tr1/ctime, tr1/cwchar, tr1/cwctype
-
-C++ Compatibility Headers for C Library Facilities
-tr1/complex.h, tr1/ctype.h, tr1/float.h, tr1/limits.h, tr1/math.h,
-tr1/stdarg.h, tr1/stdbool.h, tr1/stdint.h, tr1/stdio.h, tr1/stdlib.h,
-tr1/tgmath.h, tr1/wchar.h, tr1/wctype.h
+#include &lt;tr1/type_traits&gt;
+#include &lt;type_traits&gt;
</pre>
+<p> Several parts of C++0x diverge quite substantially from TR1 predecessors.
+</p>
+
+
<hr />
-<h2><a name="2.2">Headers and <code>namespace std::</code></a></h2>
+<h2><a name="2.2">The C Headers and <code>namespace std</code></a></h2>
<p>
- You should not use the C-headers (except for system-level
- headers) from C++ programs. Instead, you should use a set of
- headers that are named by prepending 'c' and, as usual,
- omitting the extension (.h). For example, instead of using
- <tt>&lt;math.h&gt;</tt>, you
- should use <tt>&lt;cmath&gt;</tt>. In some cases this has
- the advantage that the C++-header is more standardized than
- the C-header (i.e. <tt>&lt;ctime&gt;</tt> (almost)
- corresponds to either <tt>&lt;time.h&gt;</tt> or <tt>&lt;sys/time.h&gt;</tt>).
-
- The standard specifies that if you include the C-style header
- (<tt>&lt;math.h&gt;</tt> in
- this case), the symbols will be available both in the global
- namespace and in namespace <code>std::</code> (but
- libstdc++ does not yet have fully compliant headers) On the
- other hand, if you include only the new header (i.e. <tt>&lt;cmath&gt;</tt>), the symbols
- will only be defined in namespace <code>std::</code>
- (and macros will be converted to inline-functions).
+ The standard specifies that if one includes the C-style header
+ (&lt;math.h&gt; in this case), the symbols will be available
+ in the global namespace and perhaps in
+ namespace <code>std::</code> (but this is no longer a firm
+ requirement.) One the other hand, including the C++-style
+ header (&lt;cmath&gt;) guarantees that the entities will be
+ found in namespace std and perhaps in the global namespace.
</p>
-<p>FIXME: this is no longer accurate.</p>
-
<p>
- For more information on this, and for information on how the
- GNU C++ implementation might reuse (&quot;shadow&quot;) the C
- library-functions, have a look at <a href="http://www.cantrip.org/cheaders.html" target="_top">
- www.cantrip.org</a>.
- </p>
+Usage of C++-style headers is recommended, as then
+C-linkage names can be disambiguated by explicit qualification, such
+as by <code>std::abort</code>. In addition, the C++-style headers can
+use function overloading to provide a simpler interface to certain
+families of C-functions. For instance in &lt;cmath&gt;, the
+function <code>std::sin</code> has overloads for all the builtin
+floating-point types. This means that <code>std::sin</code> can be
+used uniformly, instead of a combination
+of <code>std::sinf</code>, <code>std::sin</code>,
+and <code>std::sinl</code>.
+</p>
+
+<hr />
+<h2><a name="2.3">Precompiled Headers</a></h2>
+
+<p>There are three base header files that are provided. They can be
+used to precompile the standard headers and extensions into binary
+files that may the be used to speed compiles that use these headers.
+</p>
+
+
+<ul>
+<li>stdc++.h
+<p>Includes all standard headers. Actual content varies depending on
+language dialect.
+</p>
+</li>
+
+<li>stdtr1c++.h
+<p>Includes all of &lt;stdc++.h&gt;, and adds all the TR1 headers.
+</p>
+</li>
+
+<li>extc++.h
+<p>Includes all of &lt;stdtr1c++.h&gt;, and adds all the Extension headers.
+</p></li>
+</ul>
+
+<p>How to construct a .gch file from one of these base header files.</p>
+
+<p>First, find the include directory for the compiler. One way to do
+this is:</p>
+
+<pre>
+g++ -v hello.cc
+
+#include <...> search starts here:
+ /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0
+...
+End of search list.
+</pre>
+
+
+<p>Then, create a precompiled header file with the same flags that
+will be used to compile other projects.</p>
+
+<pre>
+g++ -Winvalid-pch -x c++-header -g -O2 -o ./stdc++.h.gch /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h
+</pre>
+
+<p>The resulting file will be quite large: the current size is around
+thirty megabytes. </p>
+
+<p>How to use the resulting file.</p>
+
+<pre>
+g++ -I. -include stdc++.h -H -g -O2 hello.cc
+</pre>
+
+<p>Verification that the PCH file is being used is easy:</p>
+
+<pre>
+g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe
+! ./stdc++.h.gch
+. /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/iostream
+. /mnt/share/bld/H-x86-gcc.20071201include/c++/4.3.0/string
+</pre>
+
+<p>The exclamation point to the left of the <code>stdc++.h.gch</code> listing means that the generated PCH file was used, and thus the </p>
+<p></p>
+
+<p> Detailed information about creating precompiled header files can be found in the GCC <a href="http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html">documentation</a>.
+</p>
+
<hr />
-<h2><a name="2.5">Namespace <code>std::</code></a></h2>
+<h2><a name="3.0">Namespaces</a></h2>
+
+
+<p> There are three main namespaces.
+</p>
+
+<ul>
+<li>std
+<p>The ISO C++ standards specify that "all library entities are defined
+within namespace std." This includes namepaces nested
+within <code>namespace std</code>, such as <code>namespace
+std::tr1</code>.
+</p>
+</li>
+<li>abi
+<p>Specified by the C++ ABI. This ABI specifies a number of type and
+function APIs supplemental to those required by the ISO C++ Standard,
+but necessary for interoperability.
+</p>
+</li>
+
+<li>__gnu_
+<p>Indicating one of several GNU extensions. Choices
+include <code>__gnu_cxx</code>, <code>__gnu_debug</code>, <code>__gnu_parallel</code>,
+and <code>__gnu_pbds</code>.
+</p></li>
+</ul>
+
+<p> A complete list of implementation namespaces (including namespace contents) is available in the generated source <a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html">documentation</a>.
+</p>
+
+
+<hr />
+<h2><a name="3.1">Namespace <code>std::</code></a></h2>
<p>
One standard requirement is that the library components are defined
@@ -167,37 +353,46 @@ should not be used in a global context, like header files.
qualified name</i></span> for each library symbol
(i.e. <code>std::string</code>, <code>std::cout</code>) Always can be
used, and usually enhanced, by strategic use of typedefs. (In the
-cases where the qualified verbage becomes unweidly.)
+cases where the qualified verbiage becomes unwieldy.)
</p></li>
</ul></div>
<hr />
-<h2><a name="2.6">Using namespace composition</a></h2>
+<h2><a name="3.2">Using namespace composition</a></h2>
<p>
- <a href="http://gtkmm.sourceforge.net" target="_top">Gtk--</a> defines
- most of its classes in namespace Gtk::. Thus, it was possible to
- adapt Gtk-- to namespace std:: by using a C++-feature called
+Best practice in programming suggests sequestering new data or
+functionality in a sanely-named, unique namespace whenever
+possible. This is considered an advantage over dumping everything in
+the global namespace, as then name look-up can be explicitly enabled or
+disabled as above, symbols are consistently mangled without repetitive
+naming prefixes or macros, etc.
+</p>
+
+<p>For instance, consider a project that defines most of its classes in <code>namespace gtk</code>. It is possible to
+ adapt <code>namespace gtk</code> to <code>namespace std</code> by using a C++-feature called
<span class="emphasis"><i>namespace composition</i></span>. This is what happens if
- you put a <span class="emphasis"><i>using</i></span>-declaration into a
+ a <span class="emphasis"><i>using</i></span>-declaration is put into a
namespace-definition: the imported symbol(s) gets imported into the
currently active namespace(s). For example:
</p>
- <pre class="programlisting">
- namespace Gtk {
- using std::string;
- class Window { ... }
- }
- </pre>
+<pre class="programlisting">
+namespace gtk
+{
+ using std::string;
+ using std::tr1::array;
+
+ class Window { ... };
+}
+</pre>
<p>
In this example, <code>std::string</code> gets imported into
- namespace Gtk::. The result is that you don't have to use
- <code>std::string</code> in this header, but still
+ <code>namespace gtk</code>. The result is that use of
+ <code>std::string</code> inside namespace gtk can just use <code>string</code>, without the explicit qualification.
+ As an added bonus,
<code>std::string</code> does not get imported into
- the global namespace (::) unless the user does
- <code>using namespace Gtk;</code> (which is not recommended
- practice for Gtk--, so it is not a problem). Additionally, the
- <code>using</code>-declarations are wrapped in macros that
+ the global namespace. Additionally, a more elaborate arrangement can be made for backwards compatibility and portability, whereby the
+ <code>using</code>-declarations can wrapped in macros that
are set based on autoconf-tests to either &quot;&quot; or i.e. <code>using
std::string;</code> (depending on whether the system has
libstdc++ in <code>std::</code> or not). (ideas from
@@ -206,7 +401,103 @@ cases where the qualified verbage becomes unweidly.)
</p>
<hr />
-<h2><a name="3">The Standard C++ library and multithreading</a></h2>
+<h2><a name="6">Macros for libstdc++</a></h2>
+
+ <p>All pre-processor switches and configurations are all gathered
+ in the file <code>c++config.h</code>, which is generated during
+ the libstdc++ configuration and build process, and included by
+ files part of the public libstdc++ API. Most of these macros
+ should not be used by consumers of libstdc++, and are reserved
+ for internal implementation use. <strong>These macros cannot be
+ redefined</strong>. However, a select handful of these macro
+ control libstdc++ extensions and extra features, or provide
+ versioning information for the API, and are able to be used.
+ </p>
+
+ <p>All library macros begin with <code>_GLIBCXX_</code> (except for
+ versions 3.1.x to 3.3.x, which use <code>_GLIBCPP_</code>).
+ </p>
+
+ <p>Below is the macro which users may check for library version
+ information. </p>
+
+ <dl>
+ <dt><code>__GLIBCXX__</code></dt> <dd>The current version of
+ libstdc++ in compressed ISO date format, form of an unsigned
+ long. For details on the value of this particular macro for a
+ particular release, please consult this <a href="abi.html">
+ document</a>.</dd> </dl>
+
+ <p>Below are the macros which users may change with #define/#undef or
+ with -D/-U compiler flags. The default state of the symbol is
+ listed.</p>
+
+ <p>&quot;Configurable&quot; (or &quot;Not configurable&quot;) means
+ that the symbol is initially chosen (or not) based on
+ --enable/--disable options at library build and configure time
+ (documented <a href="../configopts.html">here</a>), with the
+ various --enable/--disable choices being translated to
+ #define/#undef).
+ </p>
+
+ <p> &quot;ABI&quot; means that changing from the default value may
+ mean changing the ABI of compiled code. In other words, these
+ choices control code which has already been compiled (i.e., in a
+ binary such as libstdc++.a/.so). If you explicitly #define or
+ #undef these macros, the <em>headers</em> may see different code
+ paths, but the <em>libraries</em> which you link against will not.
+ Experimenting with different values with the expectation of
+ consistent linkage requires changing the config headers before
+ building/installing the library.
+ </p>
+
+ <dl>
+ <dt><code>_GLIBCXX_DEPRECATED</code></dt>
+ <dd>Defined by default. Not configurable. ABI-changing. Turning this off
+ removes older ARM-style iostreams code, and other anachronisms
+ from the API. This macro is dependent on the version of the
+ standard being tracked, and as a result may give different results for
+ <code>-std=c++98</code> and <code>-std=c++0x</code>. This may
+ be useful in updating old C++ code which no longer meet the
+ requirements of the language, or for checking current code
+ against new language standards. </dd>
+
+ <dt><code>_GLIBCXX_FORCE_NEW</code></dt> <dd>Undefined by
+ default. When defined, memory allocation and allocators controlled
+ by libstdc++ call operator new/delete without caching and
+ pooling. Configurable via
+ <code>--enable-libstdcxx-allocator</code>. ABI-changing.
+ </dd>
+
+
+ <dt><code>_GLIBCXX_CONCEPT_CHECKS</code></dt> <dd>Undefined by
+ default. Configurable via <code>--enable-concept-checks</code>.
+ When defined, performs compile-time checking on certain template
+ instantiations to detect violations of the requirements of the
+ standard. This is described in more detail <a
+ href="../19_diagnostics/howto.html#3">here</a>.</dd>
+
+ <dt><code>_GLIBCXX_DEBUG</code></dt>
+ <dd>Undefined by default. When defined, compiles
+ user code using the <a href="../ext/debug.html#safe">libstdc++ debug
+ mode</a>.
+ </dd>
+ <dt><code>_GLIBCXX_DEBUG_PEDANTIC</code></dt>
+ <dd>Undefined by default. When defined while
+ compiling with the <a href="../ext/debug.html#safe">libstdc++ debug
+ mode</a>, makes the debug mode extremely picky by making the use
+ of libstdc++ extensions and libstdc++-specific behavior into
+ errors.
+ </dd>
+ <dt><code>_GLIBCXX_PARALLEL</code></dt>
+ <dd>Undefined by default. When defined, compiles
+ user code using the <a href="../ext/parallel_mode.html">libstdc++ parallel
+ mode</a>.
+ </dd>
+ </dl>
+
+<hr />
+<h2><a name="7">The Standard C++ library and multithreading</a></h2>
<p>This section discusses issues surrounding the proper compilation
of multithreaded applications which use the Standard C++
library. This information is GCC-specific since the C++
@@ -419,107 +710,11 @@ cases where the qualified verbage becomes unweidly.)
<a href="../faq/index.html">to the FAQ</a>.
</p>
-<hr />
-<h2><a name="6">Macros for libstdc++</a></h2>
-
- <p>All pre-processor switches and configurations are all gathered
- in the file <code>c++config.h</code>, which is generated during
- the libstdc++ configuration and build process, and included by
- files part of the public libstdc++ API. Most of these macros
- should not be used by consumers of libstdc++, and are reserved
- for internal implementation use. <strong>These macros cannot be
- redefined</strong>. However, a select handful of these macro
- control libstdc++ extensions and extra features, or provide
- versioning information for the API, and are able to be used.
- </p>
-
- <p>All library macros begin with <code>_GLIBCXX_</code> (except for
- versions 3.1.x to 3.3.x, which use <code>_GLIBCPP_</code>).
- </p>
-
- <p>Below is the macro which users may check for library version
- information. </p>
-
- <dl>
- <dt><code>__GLIBCXX__</code></dt> <dd>The current version of
- libstdc++ in compressed ISO date format, form of an unsigned
- long. For details on the value of this particular macro for a
- particular release, please consult this <a href="abi.html">
- document</a>.</dd> </dl>
-
- <p>Below are the macros which users may change with #define/#undef or
- with -D/-U compiler flags. The default state of the symbol is
- listed.</p>
-
- <p>&quot;Configurable&quot; (or &quot;Not configurable&quot;) means
- that the symbol is initially chosen (or not) based on
- --enable/--disable options at library build and configure time
- (documented <a href="../configopts.html">here</a>), with the
- various --enable/--disable choices being translated to
- #define/#undef).
- </p>
-
- <p> &quot;ABI&quot; means that changing from the default value may
- mean changing the ABI of compiled code. In other words, these
- choices control code which has already been compiled (i.e., in a
- binary such as libstdc++.a/.so). If you explicitly #define or
- #undef these macros, the <em>headers</em> may see different code
- paths, but the <em>libraries</em> which you link against will not.
- Experimenting with different values with the expectation of
- consistent linkage requires changing the config headers before
- building/installing the library.
- </p>
-
- <dl>
- <dt><code>_GLIBCXX_DEPRECATED</code></dt>
- <dd>Defined by default. Not configurable. ABI-changing. Turning this off
- removes older ARM-style iostreams code, and other anachronisms
- from the API. This macro is dependent on the version of the
- standard being tracked, and as a result may give different results for
- <code>-std=c++98</code> and <code>-std=c++0x</code>. This may
- be useful in updating old C++ code which no longer meet the
- requirements of the language, or for checking current code
- against new language standards. </dd>
-
- <dt><code>_GLIBCXX_FORCE_NEW</code></dt> <dd>Undefined by
- default. When defined, memory allocation and allocators controlled
- by libstdc++ call operator new/delete without caching and
- pooling. Configurable via
- <code>--enable-libstdcxx-allocator</code>. ABI-changing.
- </dd>
-
-
- <dt><code>_GLIBCXX_CONCEPT_CHECKS</code></dt> <dd>Undefined by
- default. Configurable via <code>--enable-concept-checks</code>.
- When defined, performs compile-time checking on certain template
- instantiations to detect violations of the requirements of the
- standard. This is described in more detail <a
- href="../19_diagnostics/howto.html#3">here</a>.</dd>
-
- <dt><code>_GLIBCXX_DEBUG</code></dt>
- <dd>Undefined by default. When defined, compiles
- user code using the <a href="../ext/debug.html#safe">libstdc++ debug
- mode</a>.
- </dd>
- <dt><code>_GLIBCXX_DEBUG_PEDANTIC</code></dt>
- <dd>Undefined by default. When defined while
- compiling with the <a href="../ext/debug.html#safe">libstdc++ debug
- mode</a>, makes the debug mode extremely picky by making the use
- of libstdc++ extensions and libstdc++-specific behavior into
- errors.
- </dd>
- <dt><code>_GLIBCXX_PARALLEL</code></dt>
- <dd>Undefined by default. When defined, compiles
- user code using the <a href="../ext/parallel_mode.html">libstdc++ parallel
- mode</a>.
- </dd>
-
<!--
<dt><code></code></dt>
<dd>
</dd>
-->
- </dl>
<p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>.
</p>
OpenPOWER on IntegriCloud