g++ namespace std & BUG?

Phil Edwards pedwards@disaster.jaj.com
Thu Aug 23 14:43:00 GMT 2001


On Thu, Aug 23, 2001 at 09:48:16AM -0500, Mark Wall wrote:
> Hello!  I was excited to successfully install gcc-3.0.1, but now I
> have compiling problems with many lines of old code.  None of the STL
> functions like "cout" work without explicitly declaring "using namespace
> std;".  I can live with that.

Well, yeah.  That's how the language and library are /supposed/ to work.
There's no bug here.

If you include the C++ headers that don't have a ".h" at the end of their
names, then everything is in namespace std.  And others have already
discussed some good rules on how to import the names.

The "old code" you're compiling can't be very old if it's using the new
headers like <iostream>.  If old code uses old headers like <iostream.h>
then 'cout' and other names are already visible.


Phil

-- 
Would I had phrases that are not known, utterances that are strange, in
new language that has not been used, free from repetition, not an utterance
which has grown stale, which men of old have spoken.
                                     - anonymous Egyptian scribe, c.1700 BC



More information about the Libstdc++ mailing list