Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Matrix3.inl  (Read 4140 times)

0 Members and 1 Guest are viewing this topic.

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] Matrix3.inl
« Reply #1 on: August 02, 2010, 08:22:18 am »
You don't have them defined in math.h?? What compiler are you using?
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
[SOLVED] Matrix3.inl
« Reply #2 on: August 02, 2010, 09:43:30 am »
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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] Matrix3.inl
« Reply #3 on: August 02, 2010, 09:50:05 am »
Quote
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.

Quote
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.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
[SOLVED] Matrix3.inl
« Reply #4 on: August 02, 2010, 10:10:40 am »
Quote from: "Laurent"
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. :)

Quote from: "Laurent"
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. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« Reply #5 on: August 02, 2010, 05:02:36 pm »
Quote from: "Laurent"
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] Matrix3.inl
« Reply #6 on: August 02, 2010, 05:25:36 pm »
It does, I'm using it too. Which version of VC++ 2008 do you have?
Laurent Gomila - SFML developer

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« Reply #7 on: August 02, 2010, 06:02:32 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] Matrix3.inl
« Reply #8 on: August 02, 2010, 06:07:32 pm »
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.
Laurent Gomila - SFML developer

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« Reply #9 on: August 02, 2010, 06:39:20 pm »
I've checked in math.h and found the sin() and cos() functions defined.

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« Reply #10 on: August 03, 2010, 05:53:28 pm »
It appears my installation is screwed up epically. This simple code fails.
Code: [Select]
#include <iostream>
#include <math.h>

int main()
{
    std::cout << sqrt(9);
    return 0;
}

This reports:
Quote

c:\documents and settings\shane\desktop\messing around\main.cpp(6) : error C3861: 'sqrt': identifier not found


This also fails:
Code: [Select]
#include <iostream>
#include <cmath>

int main()
{
    std::cout << std::sqrt(9);
    return 0;
}

It reports over one hundred errors.

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Matrix3.inl
« Reply #11 on: August 05, 2010, 03:52:17 pm »
I upgraded to VC++ 2010, and the problem seems to be fixed.