Commit a5356269 by Felix Natter Committed by Phil Edwards

porting-howto.xml: check in v0.9.4

2001-11-05  Felix Natter  <fnatter@gmx.net>

	* docs/html/17_intro/porting-howto.xml:  check in v0.9.4
	* docs/html/17_intro/porting-howto.html:  regenerate

From-SVN: r46793
parent ac4f7ad9
2001-11-05 Felix Natter <fnatter@gmx.net>
* docs/html/17_intro/porting-howto.xml: check in v0.9.4
* docs/html/17_intro/porting-howto.html: regenerate
2001-11-02 Loren J. Rittle <ljrittle@acm.org>
* include/bits/stl_threads.h (_Atomic_swap): Only enable path
......
......@@ -73,10 +73,19 @@
sec-vector-at: remove hint to modify headers
fix spelling error in sec-stringstream
</td></tr>
<tr>
<td align="left">Revision 0.9.4</td>
<td align="left">Mon Nov 5 17:01:04 2001</td>
<td align="left">fnatter</td>
</tr>
<tr><td align="left" colspan="3">
rewrite section 1.1.3 because of gnu.gcc.help-post by
Juergen Heinzl
</td></tr>
</table></div></div>
<div><div class="abstract">
<p>
<a name="id2695641"></a><b>Abstract</b>
<a name="id2697062"></a><b>Abstract</b>
</p>
<p>
Some notes on porting applications from libstdc++-2.90 (or earlier
......@@ -162,19 +171,19 @@
things:
<div class="itemizedlist"><ul>
<li><p>
<a name="id2695691"></a>wrap your code in <b>namespace std {
<a name="id2697113"></a>wrap your code in <b>namespace std {
... }</b> =&gt; This is not an option because only symbols
from the standard c++-library are defined in namespace std::.
</p></li>
<li><p>
<a name="id2695698"></a>put a kind of
<a name="id2697126"></a>put a kind of
<i>using-declaration</i> in your source (either
<b>using namespace std;</b> or i.e. <b>using
std::string;</b>) =&gt; works well for source-files, but
cannot be used in header-files.
</p></li>
<li><p>
<a name="id2695717"></a>use a <i>fully qualified name</i> for
<a name="id2697047"></a>use a <i>fully qualified name</i> for
each libstdc++-symbol (i.e. <b>std::string</b>,
<b>std::cout</b>) =&gt; can always be used
</p></li>
......@@ -257,12 +266,32 @@
<p>
If some compilers complain about <b>using
std::string;</b>, and if the &quot;hack&quot; for gtk-- mentioned above
does not work, then it might be a good idea to define a macro
NS_STD, which is defined to either &quot;&quot; or &quot;std&quot;
does not work, then I see two solutions:
<div class="itemizedlist"><ul>
<li><p>
<a name="id2698648"></a>
Define <b>std::</b> as a macro if the compiler
doesn't know about <b>std::</b>.
<pre class="programlisting">
#ifdef OLD_COMPILER
#define std
#endif
</pre>
(thanks to Juergen Heinzl who posted this solution on
gnu.gcc.help)
</p></li>
<li><p>
<a name="id2698680"></a>
Define a macro NS_STD, which is defined to
either &quot;&quot; or &quot;std&quot;
based on an autoconf-test. Then you should be able to use
<b>NS_STD::string</b>, which will evaluate to
<b>::string</b> (&quot;string in the global namespace&quot;) on
systems that do not put string in std::. (This is untested)
</p></li>
</ul></div>
</p>
</div>
<div class="section">
......@@ -276,7 +305,7 @@
</p>
<div class="table">
<p>
<a name="id2696268"></a><b>Table 1. Namespace std:: in Open-Source programs</b>
<a name="id2698746"></a><b>Table 1. Namespace std:: in Open-Source programs</b>
</p>
<table summary="Namespace std:: in Open-Source programs" border="1">
<colgroup>
......@@ -310,7 +339,7 @@
</div>
<div class="table">
<p>
<a name="id2696334"></a><b>Table 2. Notations for categories</b>
<a name="id2698876"></a><b>Table 2. Notations for categories</b>
</p>
<table summary="Notations for categories" border="1">
<colgroup>
......@@ -377,9 +406,9 @@
</p>
<p>
When using libstdc++-v3, you can use
<div class="funcsynopsis" id="id2696909">
<div class="funcsynopsis" id="id2692860">
<p>
<a name="id2696909"></a><pre class="funcsynopsisinfo">
<a name="id2692860"></a><pre class="funcsynopsisinfo">
#include &lt;fstream&gt;
</pre>
<p><code><code class="funcdef">
......@@ -473,18 +502,18 @@
fixes for existing uses of iterators.
<div class="itemizedlist"><ul>
<li><p>
<a name="id2692127"></a>you cannot do
<a name="id2693156"></a>you cannot do
<b>ostream::operator&lt;&lt;(iterator)</b> to
print the address of the iterator =&gt; use
<b>operator&lt;&lt; &amp;*iterator</b> instead ?
</p></li>
<li><p>
<a name="id2697070"></a>you cannot clear an iterator's reference
<a name="id2693255"></a>you cannot clear an iterator's reference
(<b>iterator = 0</b>) =&gt; use
<b>iterator = iterator_type();</b> ?
</p></li>
<li><p>
<a name="id2697221"></a><b>if (iterator)</b> won't work any
<a name="id2693277"></a><b>if (iterator)</b> won't work any
more =&gt; use <b>if (iterator != iterator_type())</b>
?</p></li>
</ul></div>
......@@ -669,20 +698,20 @@
</pre>
<div class="itemizedlist"><ul>
<li><p>
<a name="id2692504"></a> <b>strstream</b> is considered to be
<a name="id2693683"></a> <b>strstream</b> is considered to be
deprecated
</p></li>
<li><p>
<a name="id2692452"></a> <b>strstream</b> is limited to
<a name="id2693629"></a> <b>strstream</b> is limited to
<b>char</b>
</p></li>
<li><p>
<a name="id2692539"></a> with <b>ostringstream</b> you don't
<a name="id2693718"></a> with <b>ostringstream</b> you don't
have to take care of terminating the string or freeing its
memory
</p></li>
<li><p>
<a name="id2692552"></a> <b>istringstream</b> can be re-filled
<a name="id2693735"></a> <b>istringstream</b> can be re-filled
(clear(); str(input);)
</p></li>
</ul></div>
......
......@@ -22,6 +22,7 @@
<!-- TODO:
o remove //@label: use automatic numbering
o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/>.
o clean up the section-numbering
-->
<article class = "whitepaper" id = "libstdc++-porting-howto" lang = "en">
......@@ -88,6 +89,15 @@ o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/
fix spelling error in sec-stringstream
</revremark>
</revision>
<revision>
<revnumber>0.9.4</revnumber>
<date>Mon Nov 5 17:01:04 2001</date>
<authorinitials>fnatter</authorinitials>
<revremark>
rewrite section 1.1.3 because of gnu.gcc.help-post by
Juergen Heinzl
</revremark>
</revision>
</revhistory>
<legalnotice><title>Legal Notice</title>
<para>
......@@ -216,12 +226,31 @@ o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/
<para>
If some compilers complain about <command>using
std::string;</command>, and if the "hack" for gtk-- mentioned above
does not work, then it might be a good idea to define a macro
<symbol>NS_STD</symbol>, which is defined to either "" or "std"
does not work, then I see two solutions:
<itemizedlist>
<listitem><para>
Define <command>std::</command> as a macro if the compiler
doesn't know about <command>std::</command>.
<programlisting>
#ifdef OLD_COMPILER
#define std
#endif
</programlisting>
(thanks to Juergen Heinzl who posted this solution on
gnu.gcc.help)
</para></listitem>
<listitem><para>
Define a macro <symbol>NS_STD</symbol>, which is defined to
either "" or "std"
based on an autoconf-test. Then you should be able to use
<command>NS_STD::string</command>, which will evaluate to
<command>::string</command> ("string in the global namespace") on
systems that do not put string in std::. (This is untested)
</para></listitem>
</itemizedlist>
</para>
</section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment