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> 2001-11-02 Loren J. Rittle <ljrittle@acm.org>
* include/bits/stl_threads.h (_Atomic_swap): Only enable path * include/bits/stl_threads.h (_Atomic_swap): Only enable path
......
...@@ -73,10 +73,19 @@ ...@@ -73,10 +73,19 @@
sec-vector-at: remove hint to modify headers sec-vector-at: remove hint to modify headers
fix spelling error in sec-stringstream fix spelling error in sec-stringstream
</td></tr> </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> </table></div></div>
<div><div class="abstract"> <div><div class="abstract">
<p> <p>
<a name="id2695641"></a><b>Abstract</b> <a name="id2697062"></a><b>Abstract</b>
</p> </p>
<p> <p>
Some notes on porting applications from libstdc++-2.90 (or earlier Some notes on porting applications from libstdc++-2.90 (or earlier
...@@ -162,19 +171,19 @@ ...@@ -162,19 +171,19 @@
things: things:
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul>
<li><p> <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 ... }</b> =&gt; This is not an option because only symbols
from the standard c++-library are defined in namespace std::. from the standard c++-library are defined in namespace std::.
</p></li> </p></li>
<li><p> <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 <i>using-declaration</i> in your source (either
<b>using namespace std;</b> or i.e. <b>using <b>using namespace std;</b> or i.e. <b>using
std::string;</b>) =&gt; works well for source-files, but std::string;</b>) =&gt; works well for source-files, but
cannot be used in header-files. cannot be used in header-files.
</p></li> </p></li>
<li><p> <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>, each libstdc++-symbol (i.e. <b>std::string</b>,
<b>std::cout</b>) =&gt; can always be used <b>std::cout</b>) =&gt; can always be used
</p></li> </p></li>
...@@ -257,12 +266,32 @@ ...@@ -257,12 +266,32 @@
<p> <p>
If some compilers complain about <b>using If some compilers complain about <b>using
std::string;</b>, and if the &quot;hack&quot; for gtk-- mentioned above 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 does not work, then I see two solutions:
NS_STD, which is defined to either &quot;&quot; or &quot;std&quot;
<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 based on an autoconf-test. Then you should be able to use
<b>NS_STD::string</b>, which will evaluate to <b>NS_STD::string</b>, which will evaluate to
<b>::string</b> (&quot;string in the global namespace&quot;) on <b>::string</b> (&quot;string in the global namespace&quot;) on
systems that do not put string in std::. (This is untested) systems that do not put string in std::. (This is untested)
</p></li>
</ul></div>
</p> </p>
</div> </div>
<div class="section"> <div class="section">
...@@ -276,7 +305,7 @@ ...@@ -276,7 +305,7 @@
</p> </p>
<div class="table"> <div class="table">
<p> <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> </p>
<table summary="Namespace std:: in Open-Source programs" border="1"> <table summary="Namespace std:: in Open-Source programs" border="1">
<colgroup> <colgroup>
...@@ -310,7 +339,7 @@ ...@@ -310,7 +339,7 @@
</div> </div>
<div class="table"> <div class="table">
<p> <p>
<a name="id2696334"></a><b>Table 2. Notations for categories</b> <a name="id2698876"></a><b>Table 2. Notations for categories</b>
</p> </p>
<table summary="Notations for categories" border="1"> <table summary="Notations for categories" border="1">
<colgroup> <colgroup>
...@@ -377,9 +406,9 @@ ...@@ -377,9 +406,9 @@
</p> </p>
<p> <p>
When using libstdc++-v3, you can use When using libstdc++-v3, you can use
<div class="funcsynopsis" id="id2696909"> <div class="funcsynopsis" id="id2692860">
<p> <p>
<a name="id2696909"></a><pre class="funcsynopsisinfo"> <a name="id2692860"></a><pre class="funcsynopsisinfo">
#include &lt;fstream&gt; #include &lt;fstream&gt;
</pre> </pre>
<p><code><code class="funcdef"> <p><code><code class="funcdef">
...@@ -473,18 +502,18 @@ ...@@ -473,18 +502,18 @@
fixes for existing uses of iterators. fixes for existing uses of iterators.
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul>
<li><p> <li><p>
<a name="id2692127"></a>you cannot do <a name="id2693156"></a>you cannot do
<b>ostream::operator&lt;&lt;(iterator)</b> to <b>ostream::operator&lt;&lt;(iterator)</b> to
print the address of the iterator =&gt; use print the address of the iterator =&gt; use
<b>operator&lt;&lt; &amp;*iterator</b> instead ? <b>operator&lt;&lt; &amp;*iterator</b> instead ?
</p></li> </p></li>
<li><p> <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 = 0</b>) =&gt; use
<b>iterator = iterator_type();</b> ? <b>iterator = iterator_type();</b> ?
</p></li> </p></li>
<li><p> <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> more =&gt; use <b>if (iterator != iterator_type())</b>
?</p></li> ?</p></li>
</ul></div> </ul></div>
...@@ -669,20 +698,20 @@ ...@@ -669,20 +698,20 @@
</pre> </pre>
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul>
<li><p> <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 deprecated
</p></li> </p></li>
<li><p> <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> <b>char</b>
</p></li> </p></li>
<li><p> <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 have to take care of terminating the string or freeing its
memory memory
</p></li> </p></li>
<li><p> <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);) (clear(); str(input);)
</p></li> </p></li>
</ul></div> </ul></div>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<!-- TODO: <!-- TODO:
o remove //@label: use automatic numbering o remove //@label: use automatic numbering
o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/>. 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"> <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"/ ...@@ -88,6 +89,15 @@ o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/
fix spelling error in sec-stringstream fix spelling error in sec-stringstream
</revremark> </revremark>
</revision> </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> </revhistory>
<legalnotice><title>Legal Notice</title> <legalnotice><title>Legal Notice</title>
<para> <para>
...@@ -216,12 +226,31 @@ o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/ ...@@ -216,12 +226,31 @@ o make this work: <link linkend="sec-gtkmm-hack" endterm="sec-gtkmm-hack.title"/
<para> <para>
If some compilers complain about <command>using If some compilers complain about <command>using
std::string;</command>, and if the "hack" for gtk-- mentioned above 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 does not work, then I see two solutions:
<symbol>NS_STD</symbol>, which is defined to either "" or "std"
<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 based on an autoconf-test. Then you should be able to use
<command>NS_STD::string</command>, which will evaluate to <command>NS_STD::string</command>, which will evaluate to
<command>::string</command> ("string in the global namespace") on <command>::string</command> ("string in the global namespace") on
systems that do not put string in std::. (This is untested) systems that do not put string in std::. (This is untested)
</para></listitem>
</itemizedlist>
</para> </para>
</section> </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