SFML community forums
Help => Graphics => Topic started by: lotios611 on August 02, 2010, 01:04:42 am
-
I'm trying to develop a game engine, and have recently switched from SDL to SFML. I'm having a little trouble with sf::RenderWindow. The errors I'm getting are:
c:\sfml-1.6\include\sfml\graphics\matrix3.inl(58) : error C3861: 'cos': identifier not found
c:\sfml-1.6\include\sfml\graphics\matrix3.inl(59) : error C3861: 'sin': identifier not found
-
You don't have them defined in math.h?? What compiler are you using?
-
Laurent, why do you include <math.h> and use cos() and sin() in the global namespace instead of <cmath> and std::cos(), std::sin()? A C++ conforming implementation isn't required to supply the old C headers (even though the most probably do).
Besides, the C functions ::cos() and ::sin() use double for computation; the float overload is located inside namespace std.
-
Laurent, why do you include <math.h> and use cos() and sin() in the global namespace instead of <cmath> and std::cos(), std::sin()?
I remember some compilers not importing the functions into the std namespace, when including the C++ version of a C standard header. That's why I've always sticked to the C version.
But it was a very long time ago, probably with VC++ 6; maybe I should check again.
Besides, the C functions ::cos() and ::sin() use double for computation; the float overload is located inside namespace std.
Ok, but that shouldn't be a problem since the implicit conversion from float to double exists and is safe.
-
I remember some compilers not importing the functions into the std namespace, when including the C++ version of a C standard header. That's why I've always sticked to the C version.
But it was a very long time ago, probably with VC++ 6; maybe I should check again.
Ancient compilers also have problems with other language features (templates for example). And even if they wouldn't, I don't know whether it's a good idea to permit really old compilers to work at the expense of standard-compliant, modern compilers. :)
Ok, but that shouldn't be a problem since the implicit conversion from float to double exists and is safe.
Yes, but the float version might be more efficient. And since there's no crucial reason speaking against the <cmath> functions, you could have the possible speed-up for free. ;)
-
You don't have them defined in math.h?? What compiler are you using?
I'm using VC++ 2008. I've tested it with the sqrt() function function also. It seems that my compiler didn't come with math.h.
-
It does, I'm using it too. Which version of VC++ 2008 do you have?
-
I'm using the Express version. I've searched some more and found that math.h is there, so I have no idea why it complains.
-
Well, it's not about math.h (you would have a "header not found" error otherwise), it's about it not containing the cos and sin functions.
-
I've checked in math.h and found the sin() and cos() functions defined.
-
It appears my installation is screwed up epically. This simple code fails.
#include <iostream>
#include <math.h>
int main()
{
std::cout << sqrt(9);
return 0;
}
This reports:
c:\documents and settings\shane\desktop\messing around\main.cpp(6) : error C3861: 'sqrt': identifier not found
This also fails:
#include <iostream>
#include <cmath>
int main()
{
std::cout << std::sqrt(9);
return 0;
}
It reports over one hundred errors.
-
I upgraded to VC++ 2010, and the problem seems to be fixed.