index.html: Add tip about namespace for extensions.
2002-11-28 Jonathan Wakely <redi@gcc.gnu.org> * docs/html/faq/index.html: Add tip about namespace for extensions. From-SVN: r59613
This commit is contained in:
parent
7957fde4e8
commit
fbc3fee390
2 changed files with 31 additions and 0 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2002-11-28 Jonathan Wakely <redi@gcc.gnu.org>
|
||||||
|
* docs/html/faq/index.html: Add tip about a namespace for extensions.
|
||||||
|
|
||||||
2002-11-28 Paolo Carlini <pcarlini@unitus.it>
|
2002-11-28 Paolo Carlini <pcarlini@unitus.it>
|
||||||
Nathan Myers <ncm@cantrip.org>
|
Nathan Myers <ncm@cantrip.org>
|
||||||
|
|
||||||
|
|
|
@ -877,6 +877,34 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
|
||||||
that of other headers whose directories are not searched directly,
|
that of other headers whose directories are not searched directly,
|
||||||
e.g., <code><sys/stat.h></code>, <code><X11/Xlib.h></code>.
|
e.g., <code><sys/stat.h></code>, <code><X11/Xlib.h></code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>The extensions are no longer in the global or <code>std</code>
|
||||||
|
namespaces, instead they are declared in the <code>__gnu_cxx</code>
|
||||||
|
namespace. For maximum portability, consider defining a namespace
|
||||||
|
alias to use to talk about extensions, e.g.:
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#if __GNUC__ < 3
|
||||||
|
#include <hash_map.h>
|
||||||
|
namespace Sgi { using ::hash_map; }; // inherit globals
|
||||||
|
#else
|
||||||
|
#include <ext/hash_map>
|
||||||
|
#if __GNUC_MINOR__ == 0
|
||||||
|
namespace Sgi = std; // GCC 3.0
|
||||||
|
#else
|
||||||
|
namespace Sgi = ::__gnu_cxx; // GCC 3.1 and later
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else // ... there are other compilers, right?
|
||||||
|
namespace Sgi = std;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Sgi::hash_map<int,int> my_map; </pre>
|
||||||
|
<p>This is a bit cleaner than defining typedefs for all the
|
||||||
|
instantiations you might need.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>Extensions to the library have
|
<p>Extensions to the library have
|
||||||
<a href="../ext/howto.html">their own page</a>.
|
<a href="../ext/howto.html">their own page</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue