porting-howto.html

Felix Natter fnatter@gmx.net
Sun Apr 23 09:44:00 GMT 2000


hi,

I have attached the libstdc++-v3-porting-howto, which should
go into docs/17_intro/porting-howto.html (I gave up docbook: it was hard
to setup).
Please check this for correctness!

then I added a link in docs/17_intro/howto.html:
*** howto.html	Fri Mar 24 18:08:10 2000
--- howto-new.html	Sun Apr 23 17:51:11 2000
***************
*** 29,34 ****
--- 29,35 ----
     <LI><A HREF="#2">The Standard C++ header files</A>
     <LI><A HREF="#3">Thread-safety</A>
     <LI><A HREF="#4"><TT><foo></TT> vs <TT><foo.h></TT></A>
+    <LI><A HREF="porting-howto.html">Porting-howto</A>
  </UL>
  
  <HR>

Do I need to use any class-attributes for stylesheets ?

-- 
Felix Natter

-- 
Sent through GMX FreeMail - http://www.gmx.net
Title: Libstdc++-porting-howto




  

  

  Porting to libstdc++-v3

  
  Namespaces std
  File-flags: ios::nocreate and
  ios::noreplace
  The new headers
  Comments, suggestions, corrections, questions...
  

    
	Namespace std::
	
	  
The latest C++-standard (ISO-14882) requires that the standard C++-library
is defined in namespace std::. Thus, to use classes from the standard c++
library, you can do one of three things:

  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 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 each libstdc++-symbol
(i.e. std::string , std::cout )
=> can always be used


      
Namespace portability-issues are not a problem with g++, because versions
of g++ that do not have libstdc++ in std:: use -fno-honor-std
(ignore std:: , :: = std:: ) by default. This probably
applies to some other compilers as well.

The following sections list some possible solutions to support compilers
that cannot ignore std::.
 
      Using namespace composition if the project uses a separate
      namespace

	    
Gtk-- defines most of its
classes in namespace Gtk::. Thus, it was possible to adapt Gtk-- to
namespace std:: by using a C++-feature called namespace
composition . This is what happens if you put a
using -declaration into a namespace-definition: the imported
symbol(s) gets imported into the currently active namespace(s). This is
what it looks like in Gtk--:
namespace Gtk {
	using std::string;
	class Window { ... }
}


More information about the Libstdc++ mailing list