gcc-c++ errors for gcc version 4.7.2 20120921 (Red Hat 4.7.2-2)

S

Sharwan Joram

Hello,
I've been trying to compile a c++ project but failing with the errorsbelow :

In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:39:0,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/i686-redhat-linux/bits/c++config.h: In function ‘int main()’:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/i686-redhat-linux/bits/c++config.h:171:1: error: ‘namespace’ definition is not allowed here
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iosfwd:41:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘=’ before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected identifier before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘;’ before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected primary-expression before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘;’ before ‘__attribute__’
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/cwchar:46:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/postypes.h:42,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iosfwd:42,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/include/wchar.h:129:1: error: expected unqualified-id before string constant
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:40:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception:37:37: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception: At global scope:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception:37:37: error: expected declaration before end of line

After doing some search on google i found that is is a known issue of 4.7.2gcc-c++ , but does anyone have a fix for this ?

--Sharwan
 
A

Alf P. Steinbach

Hello,
I've been trying to compile a c++ project but failing with the errors below :

In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:39:0,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/i686-redhat-linux/bits/c++config.h: In function ‘int main()’:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/i686-redhat-linux/bits/c++config.h:171:1: error: ‘namespace’ definition is not allowed here
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iosfwd:41:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘=’ before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected identifier before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘;’ before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected primary-expression before ‘__attribute__’
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stringfwd.h:43:15: error: expected ‘;’ before ‘__attribute__’
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/cwchar:46:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/postypes.h:42,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iosfwd:42,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/include/wchar.h:129:1: error: expected unqualified-id before string constant
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:40:0,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from test.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception:37:37: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception: At global scope:
/usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/exception:37:37: error: expected declaration before end of line

After doing some search on google i found that is is a known issue of 4.7.2 gcc-c++ , but does anyone have a fix for this ?

Can you post a small program that produces this effect?

Cheers,

- Alf
 
V

Victor Bazarov

Hello,
I've been trying to compile a c++ project but failing with the errors below :

In file included from [...]

After doing some search on google i found that is is a known issue of 4.7.2 gcc-c++ , but does anyone have a fix for this ?

Try 'gnu.g++.*' newsgroup hierarchy. And if you'd like to continue
posting here, I strongly suggest starting with FAQ list. You can find
it here: http://www.parashift.com/c++-faq/ (section 5 is *very* useful,
especially question 5.8)

V
 
S

Sharwan Joram

Can you post a small program that produces this effect?



Cheers,



- Alf

This is the test program which i am trying to compile . using g++ -Wall test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World!\n";
cin.get();
}

--Sharwan
 
S

Sharwan Joram

For what it is worth, it compiles fine with g++ 4.2.2.



The errors you are getting look a lot like the sort you get when a

header you are including requires that other headers be included

before. (For example, in Unix contexts, there are lots of headers

that assume you've included <sys/types.h> first.)



Unfortunately, I'm not familiar enough with the content of the

standard headers to say what is missing.



Is there any chance that you can install a different g++ version,

since you say this is a known bug with your version?





--

Drew Lawson So risk all or don't risk anything

You can lose all the same

I will install a different g++ version, looks like there is no solution to fix this.

--Sharwan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top