Trouble compiling a trivial C++ program involving cout

Gareth Pearce tilps@hotmail.com
Fri Dec 6 07:59:00 GMT 2002



>Hi all,
>
>I have a C++ program (resource.cpp):
>
>#include "iostream"
>
>...
>
>cout << value;
>
>...
>
>On compiling with "g++ resource.cpp", I get:
>resource.cpp:18: `cout' undeclared (first use this function)
>
>I've tried:
>g++ -I /usr/include/c++/3.2/ resource.cpp
>
>in which case I get the following:
>
>cc1plus: warning: changing search order for system directory
>"/usr/include/c++/3.2"
>cc1plus: warning:   as it has already been specified as a non-system
>directory
>g++ -I /usr/include/c++/3.2/ resource.cpp
>
>I've checked and iostream is present in /usr/include/c++/3.2/
>
>I'm sure this is something trivial, but havent managed to get
>to the bottom of it after considerable digging and head scratching.
>Any help will be much appreciated.
>
>Thanks,
>-Vineet
>

It is indeed trivial - as of gcc version 3 and later - it conforms to the 
c++ standard with increased accuracy ... as such the standard library 
elements are now in namespace std.

either std::cout - or a using namespace std directive - will be required for 
your code to be conforming the c++ standard and thus compile.

Gareth

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list