This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: cerr not defined
- From: LLeweLLyn Reese <llewelly at lifesupport dot shutdown dot com>
- To: shane at shaneroberts dot com
- Cc: bjorn rohde jensen <bjensen at fastmail dot fm>, gcc-help at gcc dot gnu dot org
- Date: 22 Jan 2003 16:31:41 -0800
- Subject: Re: cerr not defined
- References: <3E2C2448.1593.2055ED52@localhost>
shane@shaneroberts.com writes:
> Bjorn,
> thank you, things are beginning to become clear.
>
> It would appear that there was an error in the Stroustrup book
It's not an error. It's explained in section 3.3, The Standard Library
Namespace (pg 46-7 in the paperback version), that Stroustrup
omits repettitive #includes and std:: qualifications, in the
interest of clarity.
> where "std::" was left off "cerr" so that it should have been:
> std::cerr << P << ' ' << P2 << '\n';
>
> for emitting the error message.
>
> This would have placed cerr in the std namespace which is
> where<fstream> places it as opposed to <fstream.h>.
>
> Since I am new to g++ and C++ can anyone clue me into when
> C++ standards changed,
Chapter 1 of the Stroustrup book contians some useful/interesting
historical information of this sort. The standard itself hasn't
changed since september 1998, when it was finalized. A round of
minor corrections, called a TC, should come by this year or next,
but no major changes will be in it.
> and g++ header files were
> relocated/changed?
http://gcc.gnu.org/releases.html
If you follow the links you'll get release notes for each gcc release.
The big change was 2.95.x => 3.x ; 2.95.x accepted std::, but treated
it as an alias for the global namespace, and had all standard
library names in the global namespace. 3.0 properly enforced
std::, and had all the appropriate standard library names in the
std:: namespace. Also, 2.95.x had older, non-compliant iostreams,
while 3.x has new iostreams.
> I just need to get my bearings so I know how to distinquish between
> "old" and "new".
[snip]
In the case of gcc, the standard headers with no suffix
(e.g. <iostream>, <fstream>, etc) are new, and try to be
conformant with standard C++, put all names in std::, have
templated streams, etc. The headers with a .h suffix are old, modeled
on older C++ ideas, like the ARM (1990), do not have namespace
std:: or templated streams, etc.