cerr not defined

shane@shaneroberts.com shane@shaneroberts.com
Mon Jan 20 20:17:00 GMT 2003


I am running gcc  version 3.2 20020927 under Cygwin  
1.3.18(0.69/3/2) 2002-12-25
on Windows XP Professional.

I am trying to compile C++ examples from the book Computer 
Graphics using Open GL by F. S. Hill, Jr.  Some of the examples 
work but now I am having trouble with the streams library.
I have included all the 32 headers found in section 17.4.1.2 of the 
C++ standard
and all of the standard C library headers (according to the same 
standard).

But "ios" continues to be "undeclared".

I have also tried compiling the standard example of stream io from 
Strousstrup's "The C++ Programming Language - Third Edition" 
page 637 section 21.5.1 File Streams.  But I get:

$ g++ testiostream.cpp
testiostream.cpp: In function `void error(const char*, const char*)':
testiostream.cpp:8: `cerr' undeclared 
(first use this function)
testiostream.cpp:8: (Each undeclared identifier is reported only 
once for each
   function it appears in.)

The code is:
_____________________Start of Code___________________
#include <fstream>
#include <cstdlib>


void error(const char* P, const char* P2 = "" )
{
	cerr << P <<  ' ' << P2 << '\n' ;
	std::exit(1) ;
}

int main(int argc, char* argv[])
{
	if(argc != 3) error( "wrong number of arguments");

	std::ifstream from( argv[1]);
	if(!from) error ("cannot open input file", argv[1]);

	std::ofstream to( argv[2]);
	if( !to ) error( "cannot open output file", argv[2]);

	char ch;
	while ( from.get(ch) ) to.put( ch ) ;

	if( !from.eof() || !to ) error( "something strange happened");

	
}
________________ End of Code_________________

Anybody know what gcc options or includes or what I need to add 
or change to make this work?

Thanks,
Shane

shane@shaneroberts.com




More information about the Gcc-help mailing list