This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Error with g++ of gcc3.1 (urgently need help)


Dear GCC team,

I've got confused about the error gcc3.1 gives me. Please do help.

I have a simple c++ program that can compile successfully with the g++ of gcc3.0.4:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
   ifstream inFile("cintest.in");
   string line;

   while (getline(inFile, line)){
      cout << line << endl;
   }

   inFile.close();

   return 0;
}


Nevertheless, when I upgraded it to gcc3.1, and tried compiling it again with g++, it gives me the following errors:

In file included from /usr/local/include/g++-v3/fstream:48,
                 from read.cpp:2:
/usr/local/include/g++-v3/bits/basic_file.h:52: parse error before `{' token
/usr/local/include/g++-v3/bits/basic_file.h:57: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:57: function `int std::overflow(int 
   = -1)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:60: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:60: function `int std::underflow()' 
   is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:63: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:63: function `int std::uflow()' is 
   initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:66: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:66: function `int 
   std::pbackfail(int)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:69: parse error before `*' token
/usr/local/include/g++-v3/bits/basic_file.h:69: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:69: function `streamsize 
   std::xsputn(...)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:72: `_CharT' was not declared in 
   this scope
/usr/local/include/g++-v3/bits/basic_file.h:72: `__s' was not declared in this 
   scope
/usr/local/include/g++-v3/bits/basic_file.h:72: parse error before `)' token
/usr/local/include/g++-v3/bits/basic_file.h:72: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:72: function `streamsize 
   std::xsgetn(...)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:76: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:76: function `streamoff 
   std::seekoff(long int, std::_Ios_Seekdir, std::_Ios_Openmode = 
   std::operator|(std::_Ios_Openmode, 
   std::_Ios_Openmode)((std::_Ios_Openmode)8, (std::_Ios_Openmode)16))' is 
   initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:80: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:80: function `streamoff 
   std::seekpos(long int, std::_Ios_Openmode = 
   std::operator|(std::_Ios_Openmode, 
   std::_Ios_Openmode)((std::_Ios_Openmode)8, (std::_Ios_Openmode)16))' is 
   initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:83: `_CharT' was not declared in 
   this scope
/usr/local/include/g++-v3/bits/basic_file.h:83: `__b' was not declared in this 
   scope
/usr/local/include/g++-v3/bits/basic_file.h:83: parse error before `)' token
/usr/local/include/g++-v3/bits/basic_file.h:83: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:83: function `std::streambuf* 
   std::setbuf(...)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:86: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:86: function `int std::sync()' is 
   initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:89: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:89: function `int std::doallocate()
   ' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:92: `_CharT' was not declared in 
   this scope
/usr/local/include/g++-v3/bits/basic_file.h:92: `__s' was not declared in this 
   scope
/usr/local/include/g++-v3/bits/basic_file.h:92: parse error before `)' token
/usr/local/include/g++-v3/bits/basic_file.h:92: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:92: function `streamsize 
   std::sys_read(...)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:95: parse error before `*' token
/usr/local/include/g++-v3/bits/basic_file.h:95: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:95: function `streamsize 
   std::sys_write(...)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:98: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:98: function `streamoff 
   std::sys_seek(long int, std::_Ios_Seekdir)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:101: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:101: function `int std::sys_close()
   ' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:104: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:104: function `int 
   std::sys_stat(void*)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:107: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:107: function `int std::showmanyc()
   ' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:110: virtual outside class 
   declaration
/usr/local/include/g++-v3/bits/basic_file.h:110: function `void 
   std::imbue(void*)' is initialized like a variable
/usr/local/include/g++-v3/bits/basic_file.h:128: '__c_wfile_type' is used as a 
   type, but is not defined as a type.
/usr/local/include/g++-v3/bits/basic_file.h:133: parse error before `*' token
/usr/local/include/g++-v3/bits/basic_file.h:136: parse error before `::' token
/usr/local/include/g++-v3/bits/basic_file.h:141: type specifier omitted for 
   parameter `ios_base'
/usr/local/include/g++-v3/bits/basic_file.h:141: parse error before `::' token
/usr/local/include/g++-v3/bits/basic_file.h:148: parse error before `::' token
/usr/local/include/g++-v3/bits/basic_file.h:185: `streamsize' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:185: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:191: `streamsize' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:191: declaration of `int 
   __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:185: conflicts with previous 
   declaration `int __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:191: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:197: `streamoff' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:197: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:204: `streamoff' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:204: declaration of `int 
   __basic_file<_CharT>::streamoff'
/usr/local/include/g++-v3/bits/basic_file.h:197: conflicts with previous 
   declaration `int __basic_file<_CharT>::streamoff'
/usr/local/include/g++-v3/bits/basic_file.h:204: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:207: `streambuf' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:207: parse error before `*' token
/usr/local/include/g++-v3/bits/basic_file.h:220: `streamsize' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:220: declaration of `int 
   __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:185: conflicts with previous 
   declaration `int __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:220: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:226: `streamsize' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:226: declaration of `int 
   __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:185: conflicts with previous 
   declaration `int __basic_file<_CharT>::streamsize'
/usr/local/include/g++-v3/bits/basic_file.h:226: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:232: `streamoff' declared as a 
   `virtual' field
/usr/local/include/g++-v3/bits/basic_file.h:232: declaration of `int 
   __basic_file<_CharT>::streamoff'
/usr/local/include/g++-v3/bits/basic_file.h:197: conflicts with previous 
   declaration `int __basic_file<_CharT>::streamoff'
/usr/local/include/g++-v3/bits/basic_file.h:232: parse error before `(' token
/usr/local/include/g++-v3/bits/basic_file.h:246: parse error before `}' token
In file included from /usr/local/include/g++-v3/bits/basic_file.h:250,
                 from /usr/local/include/g++-v3/fstream:48,
                 from read.cpp:2:
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:38: parse 
   error before `*' token
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:38: confused by earlier errors, bailing out


Can you please help? Thanks a lot!

-- 
Truely, Madly, Deeply
Tony
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.comp.nus.edu.sg/~zhoujing

If you tell the truth, you don't have to remember anything. - Mark Twain


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