From a5356269d3d2f8c1a48184c27fdfc052934ae0c4 Mon Sep 17 00:00:00 2001 From: Felix Natter Date: Mon, 5 Nov 2001 21:54:43 +0000 Subject: [PATCH] porting-howto.xml: check in v0.9.4 2001-11-05 Felix Natter * docs/html/17_intro/porting-howto.xml: check in v0.9.4 * docs/html/17_intro/porting-howto.html: regenerate From-SVN: r46793 --- libstdc++-v3/ChangeLog | 5 + .../docs/html/17_intro/porting-howto.html | 159 +++++++------ .../docs/html/17_intro/porting-howto.xml | 211 ++++++++++-------- 3 files changed, 219 insertions(+), 156 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dac1b00ed03..0b420002bb6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2001-11-05 Felix Natter + + * 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 * include/bits/stl_threads.h (_Atomic_swap): Only enable path diff --git a/libstdc++-v3/docs/html/17_intro/porting-howto.html b/libstdc++-v3/docs/html/17_intro/porting-howto.html index 582d4a6cdf2..c9a45c3bbfc 100644 --- a/libstdc++-v3/docs/html/17_intro/porting-howto.html +++ b/libstdc++-v3/docs/html/17_intro/porting-howto.html @@ -13,8 +13,8 @@

Legal Notice

- This document can be distributed under the FDL - (www.gnu.org) + This document can be distributed under the FDL + (www.gnu.org)

Tue Jun 5 20:07:49 2001

@@ -32,8 +32,8 @@ fnatter First released version using docbook-xml - + second upload to libstdc++-page. - + + second upload to libstdc++-page. + Revision 0.9 Wed Sep 6 02:59:32 2000 @@ -46,37 +46,46 @@ fnatter added information about why file-descriptors are not in the - standard + standard Revision 0.9.2 Tue Jun 5 20:07:49 2001 fnatter - a fix, added hint on increased portability of C-shadow-headers, - added autoconf-test HAVE_CONTAINER_AT - + a fix, added hint on increased portability of C-shadow-headers, + added autoconf-test HAVE_CONTAINER_AT + Revision 0.9.3 Fri Jun 29 16:15:56 2001 fnatter - changed signature of nonstandard filebuf-constructor and - update the section on filebuf::attach to point to ../ext/howto.html, - added link to ../21/strings/howto.html - in sec-stringstream, changed <link>-tags to have content - (so that these links work), - replace "user-space" by "global namespace" - add note about gcc 3.0 and shadow-headers - add section about ostream::form and istream::scan - sec-vector-at: remove hint to modify headers - fix spelling error in sec-stringstream - + changed signature of nonstandard filebuf-constructor and + update the section on filebuf::attach to point to ../ext/howto.html, + added link to ../21/strings/howto.html + in sec-stringstream, changed <link>-tags to have content + (so that these links work), + replace "user-space" by "global namespace" + add note about gcc 3.0 and shadow-headers + add section about ostream::form and istream::scan + sec-vector-at: remove hint to modify headers + fix spelling error in sec-stringstream + + +Revision 0.9.4 +Mon Nov 5 17:01:04 2001 +fnatter + + + rewrite section 1.1.3 because of gnu.gcc.help-post by + Juergen Heinzl +

-Abstract +Abstract

Some notes on porting applications from libstdc++-2.90 (or earlier @@ -162,19 +171,19 @@ things:

  • -wrap your code in namespace std { +wrap your code in namespace std { ... } => This is not an option because only symbols from the standard c++-library are defined in namespace std::.

  • -put a kind of +put a kind of using-declaration in your source (either using namespace std; or i.e. using std::string;) => works well for source-files, but cannot be used in header-files.

  • -use a fully qualified name for +use a fully qualified name for each libstdc++-symbol (i.e. std::string, std::cout) => can always be used

  • @@ -257,12 +266,32 @@

    If some compilers complain about using std::string;, and if the "hack" 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 "" or "std" - based on an autoconf-test. Then you should be able to use - NS_STD::string, which will evaluate to - ::string ("string in the global namespace") on - systems that do not put string in std::. (This is untested) + does not work, then I see two solutions: + +

      +
    • + + Define std:: as a macro if the compiler + doesn't know about std::. +

      +		#ifdef OLD_COMPILER
      +		#define std
      +		#endif
      +	      
      + (thanks to Juergen Heinzl who posted this solution on + gnu.gcc.help) +

    • +
    • + + Define a macro NS_STD, which is defined to + either "" or "std" + based on an autoconf-test. Then you should be able to use + NS_STD::string, which will evaluate to + ::string ("string in the global namespace") on + systems that do not put string in std::. (This is untested) +

    • +
    +

@@ -276,7 +305,7 @@

-Table 1. Namespace std:: in Open-Source programs +Table 1. Namespace std:: in Open-Source programs

@@ -310,7 +339,7 @@

-Table 2. Notations for categories +Table 2. Notations for categories

@@ -377,21 +406,21 @@

When using libstdc++-v3, you can use -

+

-

+
 	  #include <fstream>
 	

- basic_filebuf<...>::basic_filebuf<...> - - (file, mode, size);
__c_file_type* file;
ios_base::open_mode mode;
int size;

+ basic_filebuf<...>::basic_filebuf<...> + + (file, mode, size);
__c_file_type* file;
ios_base::open_mode mode;
int size;

but the the signature of this constructor has changed often, and it might change again. For the current state of this, check - the howto for extensions. -

+ the howto for extensions. +

For a portable solution (among systems which use filedescriptors), you need to implement a subclass of @@ -410,8 +439,8 @@ source-code.

- The old C++-headers (iostream.h etc.) are available, but gcc generates - a warning that you are using deprecated headers. + The old C++-headers (iostream.h etc.) are available, but gcc generates + a warning that you are using deprecated headers.

@@ -441,7 +470,7 @@ For more information on this, and for information on how the GNU C++ implementation might reuse ("shadow") the C library-functions, have a look at - www.cantrip.org. + www.cantrip.org.

@@ -455,8 +484,8 @@ In earlier versions of the standard, <fstream.h>, <ostream.h> - and <istream.h> - used to define + and <istream.h> + used to define cout, cin and so on. Because of the templatized iostreams in libstdc++-v3, you need to include <iostream> @@ -473,18 +502,18 @@ fixes for existing uses of iterators.
  • -you cannot do +you cannot do ostream::operator<<(iterator) to print the address of the iterator => use operator<< &*iterator instead ?

  • -you cannot clear an iterator's reference +you cannot clear an iterator's reference (iterator = 0) => use iterator = iterator_type(); ?

  • -if (iterator) won't work any +if (iterator) won't work any more => use if (iterator != iterator_type()) ?

@@ -501,7 +530,7 @@ <ctype.h> -functionality as macros (isspace, isalpha etc.). Libstdc++-v3 "shadows" these macros as described in the section about - c-headers. + c-headers.

Older implementations of libstdc++ (g++-2 for egcs 1.x and g++-3 @@ -552,8 +581,8 @@ --enable-cshadow-headers is currently broken. As a result, shadow headers are not being searched.... ' - This is now outdated, but gcc 3.0 still does not have fully - compliant "shadow headers". + This is now outdated, but gcc 3.0 still does not have fully + compliant "shadow headers".

@@ -646,10 +675,10 @@ 11. GNU Extensions ostream::form and istream::scan

- These are not supported any more - use - - stringstreams instead. -

+ These are not supported any more - use + + stringstreams instead. +

@@ -669,20 +698,20 @@
  • - strstream is considered to be + strstream is considered to be deprecated

  • - strstream is limited to + strstream is limited to char

  • - with ostringstream you don't + with ostringstream you don't have to take care of terminating the string or freeing its memory

  • - istringstream can be re-filled + istringstream can be re-filled (clear(); str(input);)

@@ -739,18 +768,18 @@ void fromString(const string& input, X& any) { #ifdef HAVE_SSTREAM - std::istringstream iss(input); + std::istringstream iss(input); #else - std::istrstream iss(input.c_str()); + std::istrstream iss(input.c_str()); #endif - X temp; - iss >> temp; - if (iss.fail()) - throw runtime_error(..) - any = temp; + X temp; + iss >> temp; + if (iss.fail()) + throw runtime_error(..) + any = temp; } - Another example of using stringstreams is in this howto. + Another example of using stringstreams is in this howto.

I have read the Josuttis book on Standard C++, so some information diff --git a/libstdc++-v3/docs/html/17_intro/porting-howto.xml b/libstdc++-v3/docs/html/17_intro/porting-howto.xml index f00d047989c..1c028433355 100644 --- a/libstdc++-v3/docs/html/17_intro/porting-howto.xml +++ b/libstdc++-v3/docs/html/17_intro/porting-howto.xml @@ -22,6 +22,7 @@

@@ -36,63 +37,72 @@ o make this work: - 0.5 - Thu Jun 1 13:06:50 2000 - fnatter - First docbook-version. + 0.5 + Thu Jun 1 13:06:50 2000 + fnatter + First docbook-version. - 0.8 - Sun Jul 30 20:28:40 2000 - fnatter - First released version using docbook-xml - + second upload to libstdc++-page. - + 0.8 + Sun Jul 30 20:28:40 2000 + fnatter + First released version using docbook-xml + + second upload to libstdc++-page. + - 0.9 - Wed Sep 6 02:59:32 2000 - fnatter - 5 new sections. + 0.9 + Wed Sep 6 02:59:32 2000 + fnatter + 5 new sections. - 0.9.1 - Sat Sep 23 14:20:15 2000 - fnatter - added information about why file-descriptors are not in the - standard + 0.9.1 + Sat Sep 23 14:20:15 2000 + fnatter + added information about why file-descriptors are not in the + standard - 0.9.2 - Tue Jun 5 20:07:49 2001 - fnatter - - a fix, added hint on increased portability of C-shadow-headers, - added autoconf-test HAVE_CONTAINER_AT - + 0.9.2 + Tue Jun 5 20:07:49 2001 + fnatter + + a fix, added hint on increased portability of C-shadow-headers, + added autoconf-test HAVE_CONTAINER_AT + - 0.9.3 - Fri Jun 29 16:15:56 2001 - fnatter - - changed signature of nonstandard filebuf-constructor and - update the section on filebuf::attach to point to ../ext/howto.html, - added link to ../21/strings/howto.html - in sec-stringstream, changed <link>-tags to have content - (so that these links work), - replace "user-space" by "global namespace" - add note about gcc 3.0 and shadow-headers - add section about ostream::form and istream::scan - sec-vector-at: remove hint to modify headers - fix spelling error in sec-stringstream - + 0.9.3 + Fri Jun 29 16:15:56 2001 + fnatter + + changed signature of nonstandard filebuf-constructor and + update the section on filebuf::attach to point to ../ext/howto.html, + added link to ../21/strings/howto.html + in sec-stringstream, changed <link>-tags to have content + (so that these links work), + replace "user-space" by "global namespace" + add note about gcc 3.0 and shadow-headers + add section about ostream::form and istream::scan + sec-vector-at: remove hint to modify headers + fix spelling error in sec-stringstream + + + + 0.9.4 + Mon Nov 5 17:01:04 2001 + fnatter + + rewrite section 1.1.3 because of gnu.gcc.help-post by + Juergen Heinzl + Legal Notice - This document can be distributed under the FDL - (www.gnu.org) + This document can be distributed under the FDL + (www.gnu.org) @@ -216,12 +226,31 @@ o make this work: If some compilers complain about using std::string;, and if the "hack" 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 "" or "std" - based on an autoconf-test. Then you should be able to use - NS_STD::string, which will evaluate to - ::string ("string in the global namespace") on - systems that do not put string in std::. (This is untested) + does not work, then I see two solutions: + + + + Define std:: as a macro if the compiler + doesn't know about std::. + + #ifdef OLD_COMPILER + #define std + #endif + + (thanks to Juergen Heinzl who posted this solution on + gnu.gcc.help) + + + + Define a macro NS_STD, which is defined to + either "" or "std" + based on an autoconf-test. Then you should be able to use + NS_STD::string, which will evaluate to + ::string ("string in the global namespace") on + systems that do not put string in std::. (This is untested) + + + @@ -288,7 +317,7 @@ o make this work: section on the gtkmm-hack). + endterm="sec-gtkmm-hack.title">section on the gtkmm-hack). @@ -330,19 +359,19 @@ o make this work: - basic_filebuf<...>::basic_filebuf<...> - - - __c_file_type* file + basic_filebuf<...>::basic_filebuf<...> + + + __c_file_type* file ios_base::open_mode mode int size but the the signature of this constructor has changed often, and it might change again. For the current state of this, check - the howto for extensions. - - + the howto for extensions. + + For a portable solution (among systems which use filedescriptors), you need to implement a subclass of std::streambuf (or @@ -359,8 +388,8 @@ o make this work: . - The old C++-headers (iostream.h etc.) are available, but gcc generates - a warning that you are using deprecated headers. + The old C++-headers (iostream.h etc.) are available, but gcc generates + a warning that you are using deprecated headers.
@@ -372,13 +401,13 @@ o make this work: <math.h>, you should use <cmath>. In some cases this has + "headerfile"><cmath>. In some cases this has the advantage that the C++-header is more standardized than the C-header (i.e. <ctime> (almost) + class="headerfile"><ctime> (almost) corresponds to either <time.h> or <sys/time.h>). + "headerfile"><time.h> or <sys/time.h>). The standard specifies that if you include the C-style header (<math.h> in @@ -386,7 +415,7 @@ o make this work: std:: (but libstdc++ does not yet have fully compliant headers) On the other hand, if you include only the new header (i.e. <cmath>), the symbols + class = "headerfile"><cmath>), the symbols will only be defined in namespace std:: (and macros will be converted to inline-functions). @@ -394,8 +423,8 @@ o make this work: - www.cantrip.org. + url="http://www.cantrip.org/cheaders.html"> + www.cantrip.org.
@@ -408,8 +437,8 @@ o make this work: <fstream.h>, <ostream.h> - and <istream.h> - used to define + and <istream.h> + used to define cout, cin and so on. Because of the templatized iostreams in libstdc++-v3, you need to include <iostream> @@ -452,8 +481,8 @@ o make this work: <ctype.h> -functionality as macros (isspace, isalpha etc.). Libstdc++-v3 "shadows" these macros as described in the section about - c-headers. + linkend="sec-cheaders" endterm="sec-cheaders.title">section about + c-headers. Older implementations of libstdc++ (g++-2 for egcs 1.x and g++-3 @@ -478,7 +507,7 @@ o make this work: <ctype.h> to define functions + class="headerfile"><ctype.h> to define functions instead of macros: // This keeps isalnum, et al from being propagated as macros. @@ -492,7 +521,7 @@ o make this work: Another problem arises if you put a using namespace std; declaration at the top, and include <ctype.h>. This will result in + = "headerfile"><ctype.h>. This will result in ambiguities between the definitions in the global namespace (<ctype.h>) and the definitions in namespace std:: @@ -506,8 +535,8 @@ o make this work: - This is now outdated, but gcc 3.0 still does not have fully - compliant "shadow headers". + This is now outdated, but gcc 3.0 still does not have fully + compliant "shadow headers". @@ -593,12 +622,12 @@ o make this work:
- GNU Extensions ostream::form and istream::scan - - These are not supported any more - use - - stringstreams instead. - + GNU Extensions ostream::form and istream::scan + + These are not supported any more - use + + stringstreams instead. +
@@ -606,10 +635,10 @@ o make this work: Libstdc++-v3 provides the new i/ostringstream-classes, (<sstream>), but for compatibility + class="headerfile"><sstream>), but for compatibility with older implementations you still have to use i/ostrstream (<strstream>): + class="headerfile"><strstream>): #ifdef HAVE_SSTREAM #include <sstream> @@ -689,19 +718,19 @@ o make this work: > temp; - if (iss.fail()) - throw runtime_error(..) - any = temp; + X temp; + iss >> temp; + if (iss.fail()) + throw runtime_error(..) + any = temp; } - Another example of using stringstreams is in this howto. + Another example of using stringstreams is in this howto. I have read the Josuttis book on Standard C++, so some information -- 2.30.2