Topic: The std namespace
Author: "Mike Wahler" <mkwahler@mkwahler.net>
Date: 2000/08/13 Raw View
Nobody <thenameisnobody@hotmail.com> wrote in message
news:J0_k5.12904$h3.142620@news000.worldonline.dk...
> Why does the content of fx. iostream.h become a part of the global
namespace
> when included like this:
> #include <iostream.h>
>
> but not when included like this:
> #include <iostream>
>
> (the complier is bcc32)
>
>
> Martin
Because <iostream> is standard, and <iostream.h> is not.
I.e. your compiler is free to implement <iostream.h> any
way it chooses, since it's not a standard entity.
-Mike
>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Ken Bloom" <ken195@bigfoot.com>
Date: 2000/08/14 Raw View
"Nobody" <thenameisnobody@hotmail.com> wrote in message
news:J0_k5.12904$h3.142620@news000.worldonline.dk...
> Why does the content of fx. iostream.h become a part of the global
namespace
> when included like this:
> #include <iostream.h>
>
> but not when included like this:
> #include <iostream>
>
> (the complier is bcc32)
The file iostream.h is NOT ANSI STANDARD. It exists on compilers to emulate
the AT&T cfront iostreams which were not put in a special namespace because
namespace support did not exist in AT&T cfront (nor did it exist in the
ARM.)
Use iostream.h only for compatibility with pre-ANSI programs.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Max Polk <x@x.invalid>
Date: 2000/08/14 Raw View
In article <J0_k5.12904$h3.142620@news000.worldonline.dk>,
thenameisnobody@hotmail.com says...
> Why does the content of fx. iostream.h become a part of the global namespace
> when included like this:
> #include <iostream.h>
>
> but not when included like this:
> #include <iostream>
>
> (the complier is bcc32)
Including "iostream.h" is not according to standard -- see 17.4.1.2,
section 2 in the C++ standard where it says to use <iostream>. As
compiler writers make them work closer and closer to the standard, you
will need to make your code closer and closer to the standard.
In 2.8, section 1 (and possible also in 16.2, section 5), it states that
the mapping of a header include (like "iostream") to its corresponding
source file name is implementation-defined. This means, in part, that it
would be okay for the compiler vendor to name the header
"iostream.qwerty" if they wished.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Nobody" <thenameisnobody@hotmail.com>
Date: 2000/08/11 Raw View
Why does the content of fx. iostream.h become a part of the global namespace
when included like this:
#include <iostream.h>
but not when included like this:
#include <iostream>
(the complier is bcc32)
Martin
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Michael Rubenstein <mike@mrubenstein.com>
Date: 2000/08/12 Raw View
On Fri, 11 Aug 2000 21:56:41 GMT, "Nobody"
<thenameisnobody@hotmail.com> wrote:
>Why does the content of fx. iostream.h become a part of the global namespace
>when included like this:
>#include <iostream.h>
>
>but not when included like this:
>#include <iostream>
>
>(the complier is bcc32)
<iostream.h> is a nonstandard header -- an implementation may do
anything it likes with it, including not implement it at all.
However, it is common for implementations to provide <iostream.h>
for compatibility. Prestandard compilers used that header (among
others) for iostreams. Such compilers generally did not support
namespaces or put the standard types, objects, and functions in
namespace std, hence <iostream.h>, hence <iostream.h> allows
access to these without specifying a namespace.
Beware. Since this (and the other .h headers except those
inheritted from C) is nonstandard, different compilers do it
differently. Borland's <iostream.h> provides the same
functionality as <iostream> but has a using namespace std; to
allow access without specifying the namespace. Others behave
differently. For example, Microsoft's <iostream.h> provides a
different set of classes and objects that provide different
functionality, are incompatible with the standard classes and are
not in namespace std.
For example, the program
#include <iostream.h>
int main()
{
std::cout << "hello world\n";
return 0;
}
will compile under Borland but not Microsoft (current compilers
used).
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Victor Bazarov" <vAbazarov@dAnai.com>
Date: 2000/08/13 Raw View
"Nobody" <thenameisnobody@hotmail.com> wrote...
> Why does the content of fx. iostream.h become a part of the global
namespace
> when included like this:
> #include <iostream.h>
>
> but not when included like this:
> #include <iostream>
>
> (the complier is bcc32)
Because bcc32's non-standard header is probably written like this:
#ifndef IOSTREAM_H
#define IOSTREAM_H
#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::clog;
using std::wcin;
using std::wcout;
using std::wcerr;
using std::wclog;
#endif
That brings all symbols <iostream> declares INSIDE std namespace
to the current scope (which happens to be global in your program).
Victor
--
Please remove capital A's from my address when replying by mail
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]