This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: STL headers problem
- To: egcs at cygnus dot com
- Subject: Re: STL headers problem
- From: Nathan Myers <ncm at cygnus dot com>
- Date: Wed, 29 Jul 1998 19:23:24 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <35BE3012.E71D4BA2@cygnus.com>, <199807291605.JAA06351.cygnus.egcs@atrus.synopsys.com>
Joe Buck wrote:
>
> > If your code doesn't mention namespaces, you'll be better off using
> > <vector.h> than using <vector> today. That way when the new libraries
> > come out you will change a simple compiler flag to keep your code
> > working; otherwise everything breaks.
>
> Actually, if the program says
>
> #include <vector>
> using namespace std;
>
> it will work before and after the conversion (since std is currently a
> "dummy") and even be portable (however, the user will have to avoid
> using any of the names in the std namespace).
This is really rolling out the big guns. For vector,
#include <vector>
using std::vector;
has the same useful effect without the smoke and carnage. In fact, this
is what <vector.h> has in it (look!). To make your code portable later,
you can provide your own "vector.h" with that in it, if you like.
Of course some of the other headers define many more global names. Still,
using-directives like Joe suggests invite trouble; a few using-declarations
as I have suggested above costs very little and helps keep your hair thick
and dark.
The "using namespace" using-directive is *not* your friend.
Nathan Myers
ncm@cantrip.org