Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Galileo430

sqrtf ??

This topic is 6415 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

Due to buget reasons I am still codeing around with Visual C++ 4.0 I when ever I compile D3d8math.h, I get "can''t find function sqrtf". I added Math.h to the program. It did not work.. Anyone know where I can find that function?

Share this post


Link to post
Share on other sites
Advertisement
It exists in Visual C++ 5 and 6 (well, not too sure about 5). You can get around it by putting #define sqrtf (float)sqrt in your source file or -Dsqrtf=(float)sqrt as a command line argument to the compiler. The latter is what the sdk makefile does for borland compilers (which also don''t have the sqrtf function).

Share this post


Link to post
Share on other sites
here''s the code.


float sqrtf(float f)
{
float fResult;

__asm {
fld f
fsqrt
fstp fResult
}
return (fResult);
}


hope this helps.

Share this post


Link to post
Share on other sites
All those math functions (sinf, cosf, atan2f, sqrtf) are non-standard functions, which makes sharing code a pain in the butt. I work in Borland C++ Builder 5 and use code written with Visual C++ 6.0. I work around the problem of the missing functions by setting up macros to make them into standard functions.

#ifdef __BORLANDC__
#define sinf(x) (float)sin((float)x)
#define sqrtf(x) (float)sqrt((float)x)
#endif

There are many other annoyances when using Visual C++ code with a much stricter ANSI-compliant compiler such as Borland C++ 5.5, but I will let those pass for now.



Steve ''Sly'' Williams
Tools Developer
Krome Studios

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!