Re: cout undeclared in 10.2
Re: cout undeclared in 10.2
- Subject: Re: cout undeclared in 10.2
- From: "Clark S. Cox III" <email@hidden>
- Date: Mon, 26 Aug 2002 13:50:38 -0400
On 08/26/2002 13:08, "John Nairn" <email@hidden> wrote:
>
I just upgraded to 10.2. When I rebuilt a C++ Tool that worked fine
>
before, it now quickly fails to compile and says 'cout', 'cerr', and
>
'endl'. As of the previous version of ProjectBuilder, this code had all
>
the needed includes and linked to all needed libraries. Now it no
>
longer works?
You must do one of the following in your code:
1) #include <iostream> //Notice, <iostream> not <iostream.h>
using std::cout;
using std::cerr;
using std::endl;
2) #include <iostream> //Notice, <iostream> not <iostream.h>
using namespace std;
3) #include <iostream> //Notice, <iostream> not <iostream.h>
Replace every instance of cout with std::cout
Replace every instance of cerr with std::cerr
Replace every instance of endl with std::endl
The previous versions of the compiler were too lenient when it came to
namespaces, and allowed non-standard code to compile, the newer version now
(correctly) says that cout, cerr and endl, are undefined, as they belong in
the "std" namespace.
BTW, for future reference, if it fails during compiling (and not
linking), the libraries linked to are irrelevant
--
Clark S. Cox III
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.