Jump to content
  • Advertisement
Sign in to follow this  
AWilson

error C2666 VC++ 05, help!

This topic is 4060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heres my error: ///// error C2666: 'fmod' : 3 overloads have similar conversions c:\program files\microsoft visual studio 8\vc\include\math.h(561): could be 'long double fmod(long double,long double)' c:\program files\microsoft visual studio 8\vc\include\math.h(513): or 'float fmod(float,float)' c:\program files\microsoft visual studio 8\vc\include\math.h(120): or 'double fmod(double,double)'while trying to match the argument list '(float, double)' ///// How can I fix this?

Share this post


Link to post
Share on other sites
Advertisement
Since you didn't post any code, I can't be sure, but here's what I think is happening:

You are calling the fmod function like so:
fmod(1.0, 0.0);

In which case, the compiler can interpret those numbers as floats, doubles, or long doubles, so it doesn't know what to do. You can make it explicit by either putting in casts, or, for the float version, appending the letter 'f' to each of the numbers:
//call fmod(double, double)
fmod(static_cast<double>(1.0), static_cast<double>(0.0));

//call fmod(float, float)
fmod(1.f, 0.f);

Share this post


Link to post
Share on other sites
Coerce the arguments to the appropriate function call in to the same type.

e.g.

fmod(static_cast<double>(x), static_cast<double>(y));



Put yourself in the compiler's shoes. If you were asked to compile fmod(x, y) where x is a float and y is a double, which overload would you choose?

Share this post


Link to post
Share on other sites
Quote:
Original post by Driv3MeFar
You are calling the fmod function like so:
fmod(1.0, 0.0);

In which case, the compiler can interpret those numbers as floats, doubles, or long doubles, so it doesn't know what to do.

Those are both doubles, so that should compile just fine. What is more likely is that one of the parameters is a variable of type float and the other paramter is a constant without F appended to it. For example,
fmod(x,0.5);

where x is a variable of type float. For some reason people tend to use floats when using variables, but doubles when using immediates.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!