This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Trouble compiling a trivial C++ program involving cout



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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]