Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmath.h and compile errors

I used to work with math.h without any problem. Now, I use an external library which itself has a file called math.h, but which includes < cmath>.

Adding this library to my project (or even just adding the include directory, without touching the code) now generates tons of errors from < cmath> :

C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2039: 'acosf' : is not a member of '`global namespace''

C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2873: 'acosf' : symbol cannot be used in a using-declaration

C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2039: 'asinf' : is not a member of '`global namespace''

C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2873: 'asinf' : symbol cannot be used in a using-declaration

[etc, etc...]

I don't understand why this happens. I am using Visual Studio 2005 and looking on the internet, it seems that this problem is solved under VS 2008. However, I'd like to stay on VS 2005...

Including using namespace std; everywhere, or changing the order of my includes doesn't seem to change anything. Defining _STD_BEGIN solves the error, but produce as many in < xlocinfo>.

How can this be solved?

like image 890
nbonneel Avatar asked Oct 21 '10 00:10

nbonneel


2 Answers

Same Problem exists in VC 10. I think, that <cmath> includes itself a math.h but insted of the correct one, which is shipped with VC it uses the one which is created in the User-Project (with different content of course).

Solution: Do never use a File named math.h in your Project... (Or correct the std somewhere).

like image 115
Knox Avatar answered Nov 16 '22 02:11

Knox


I'm not sure I read your question correctly but it seems odd that a library would ship it's own math.h file.

Perhaps you are suppose to put the parent directory in your include path so that <my_lib/math.h> can be included without conflicting with your compiler <math.h>?

like image 32
Alex Jasmin Avatar answered Nov 16 '22 01:11

Alex Jasmin