Question

I'm doing a project in c++ using OpenGL and keep getting hit with hundreds of syntax errors from cmath.h. The main puzzle is that I'm not even refering to or including cmath at all. I'm using math.h in one or two things but that code was working perfectly before I made recent changes. Going back to the previously working code now shows the same errors so I'm kind of stumped on where to start looking.

Am I missing something really obvious or could this be a Visual Studio 10 issue?

Was it helpful?

Solution

Probably because there is no (standard) cmath.h

The C math header is math.h and C++ also exposes this library but as just cmath, however all the elements of it are lifted into the std:: namespace.

In a C++ project you should include the library like so:

 #include <cmath>

and use it's elements like:

 c=std::sqrt(
       std::pow(a,2)
      +std::pow(b,2));

or whatever else you have going on.

references

http://en.cppreference.com/w/cpp/numeric/math

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top