c++ code not compiling in RH9

M

mike

Hi

I wrote some code ages ago when I was not very hot on c++ but it
worked just fine. I had no problems compiling it on redhat 7.3 but
that box died recently so I tried compiling the code on my new RH 9
box and got the following error

In file included from /usr/include/c++/3.2.2/cstdlib:52,
from /usr/include/c++/3.2.2/bits/stl_algobase.h:67,
from /usr/include/c++/3.2.2/memory:54,
from /usr/include/c++/3.2.2/string:48,
from /usr/include/c++/3.2.2/bits/localefwd.h:49,
from /usr/include/c++/3.2.2/ios:48,
from /usr/include/c++/3.2.2/ostream:45,
from /usr/include/c++/3.2.2/iostream:45,
from lapackcmplx.h:8,
from tmatrix.cpp:2:
/usr/include/stdlib.h:742: parse error before `int'
In file included from /usr/include/c++/3.2.2/bits/stl_algobase.h:67,
from /usr/include/c++/3.2.2/memory:54,
from /usr/include/c++/3.2.2/string:48,
from /usr/include/c++/3.2.2/bits/localefwd.h:49,
from /usr/include/c++/3.2.2/ios:48,
from /usr/include/c++/3.2.2/ostream:45,
from /usr/include/c++/3.2.2/iostream:45,
from lapackcmplx.h:8,
from tmatrix.cpp:2:
/usr/include/c++/3.2.2/cstdlib:90: `abs' not declared

can anyone shed any light on this?

Thanks
Mike
 
M

mike

Gianni Mariani said:
I think "abs" is not declared.

That much is clear - what I am wondering is why was it declared when I
compiled it under RH 7.3 but it is not under RH 9.
 
G

Gavin Deane

That much is clear - what I am wondering is why was it declared when I
compiled it under RH 7.3 but it is not under RH 9.

So am I. But without seeing the code I would be guessing. I can get
the error Gianni singled out with this:

int main()
{
abs(42);
return 0;
}

But I suspect your problem is more complicated.

GJD
 
K

Kevin Goodsell

mike said:
That much is clear - what I am wondering is why was it declared when I
compiled it under RH 7.3 but it is not under RH 9.

My guess would be that RH 9 comes with a much more up to date version of
the compiler (7, IIRC, didn't even come with a "real" gcc - it was an
unofficial version that wasn't supposed to be released).

Chances are, if this version of gcc says there's an error it the code,
there's an error in the code, and the old version was wrong to accept it.

I suspect the problem may be that you are using abs() rather than
std::abs(), and you don't have an appropriate 'using' declaration.

-Kevin
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top