PDA

View Full Version : CL 2.0.3 - problem with gcc 4.0.0 /4.2.0



iQD
05-29-2009, 09:02 PM
Hi,

i tried to compile 2.0.3 with gcc 4.0.0 an gcc 4.2.0 on OS X.

There's the file math.h in API/Core/Math which includes <cmath>.
cmath itself includes <math.h>.

So the compiler gives following error(s):
(for exmple compiling init_linux.cpp, angle.cpp etc.)

/usr/include/c++/4.0.0/cmath:99: error: '::acos' has not been declared
/usr/include/c++/4.0.0/cmath:378: error: '::sinh' has not been declared

[...]

/usr/include/c++/4.0.0/cmath:408: error: '::tan' has not been declared
/usr/include/c++/4.0.0/cmath:423: error: '::tanh' has not been declared

Seems that the local math.h file is clashing with the system header math.h .

After i renamed the local math.h (to cl_math.h) it worked fine.

Compiling on Linux and Windows with actual gcc works without renaming.

The question:
1. Anyone knows of a compiler bug? special compiler options?
2. Wouldn't it be much better to rename the local math.h for compatibility? (if its not a compiler bug)
3. Are there some include guards possible (tried some #ifdef _MATH_H, #ifdef _CL_MATH_ etc. but neither worked)?

After searching google, some guys mentioned, that they have those problems also with other libs (other than clanlib) and >= gcc 4.3.x etc.

Thanks for your time.

rombust
05-29-2009, 09:37 PM
i tried to compile 2.0.3 with gcc 4.0.0 an gcc 4.2.0 on OS X.

How did everything else compile? As far as I know, nobody has tried compiling ClanLib V2.0 on OS X


Seems that the local math.h file is clashing with the system header math.h .

Odd! I can't work out what is going wrong here. I'm a bit too tired to work out the internals of #include ( http://msdn.microsoft.com/en-us/library/36k2cdd4(VS.71).aspx )

sphair
05-29-2009, 10:15 PM
I'm doing a cleanup of math.h now and will probably rename it to something else.

iQD
05-29-2009, 11:01 PM
How did everything else compile? As far as I know, nobody has tried compiling ClanLib V2.0 on OS X


I already compiled Core and Network.
Trieed to solve de math.h prob. OS X gcc is a modified gcc by Apple.

Have to create some Frameworks for PCRE and freetype2 for the other targƒets.

Nobody did yep, so i will start :)



Odd! I can't work out what is going wrong here. I'm a bit too tired to work out the internals of #include ( http://msdn.microsoft.com/en-us/library/36k2cdd4(VS.71).aspx )

No problem.
I also have no clue. Checked several gcc MLs, asked some coders etc. All have the same problems with cmath. Especially on OS X and older gcc.

I will check on my other systems if it depends on some gcc versions or if it's just another OS X "feature".


I'm doing a cleanup of math.h now and will probably rename it to something else.

Thanks.
I can just confirm, that a renamed math.h worked on gcc 4.0.x, 4.2.x and LLVM 4.2.x