Subject: GCC3 problems with C++ fstream
From: "Gerrit P. Haase" <[email-masked]>
To: [email-masked]
Date: Mon, 12 Aug 2002 18:48:02 +0200

Hallo,

Code:
=====
#include <fstream>
void main() //the program starts here
{
ofstream SaveFile("cygwin.txt");
SaveFile << "Hello World, this works with gcc-2 but not with gcc-3!";
SaveFile.close();
}

GCC3:
=====
$ g++ --version
g++ (GCC) 3.1.1 20020718 (prerelease)

$ g++ -o fstream fstream.cpp
In file included from /usr/include/g++-3/streambuf.h:36,
                 from /usr/include/g++-3/iostream.h:31,
                 from /usr/include/g++-3/fstream.h:30,
                 from /usr/include/g++-3/fstream:6,
                 from fstream.cpp:1:
/usr/include/g++-3/libio.h:30:23: _G_config.h: No such file or directory
In file included from /usr/include/g++-3/streambuf.h:36,
                 from /usr/include/g++-3/iostream.h:31,
                 from /usr/include/g++-3/fstream.h:30,
                 from /usr/include/g++-3/fstream:6,
                 from fstream.cpp:1:
/usr/include/g++-3/libio.h:239: '_G_off_t' is used as a type, but is not 
   defined as a type.
/usr/include/g++-3/libio.h:279: `read' was not declared in this scope

[...and on...]

I wonder: why is not included:
/usr/include/c++/3.1.1/fstream
but /usr/include/g++-3/fstream?

GCC2:
=====
$ g++-2 --version
2.95.3-9

$ g++-2 -o fstream fstream.cpp

$ cat cygwin.txt
cat: cygwin.txt: No such file or directory

$ ./fstream

$ cat cygwin.txt
Hello World, this works with gcc-2 but not with gcc-3!

Is just _G_config.h missing in the Cygwin dist of GCC3?
If I remove GCC2 I get a different behaviour:

$ g++ -o fstream fstream.cpp
fstream.cpp:4: `main' must return `int'
fstream.cpp: In function `int main(...)':
fstream.cpp:6: `ofstream' undeclared (first use this function)
fstream.cpp:6: (Each undeclared identifier is reported only once for each 
   function it appears in.)
fstream.cpp:6: parse error before `(' token
fstream.cpp:8: `SaveFile' undeclared (first use this function)

Hmmm...

Gerrit
-- 
"All faults& bugs are mine - Robert"
    from squid/acinclude.m4,   Sun Apr 21 05:21:21 2002

--
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/