Jump to content
  • Advertisement

Archived

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

Teric

VC++6.0 to VC++7.0 Problems

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

I''ve just converted to VC++7.0, and I''m already running into some problems. Under version 6.0, I could explicitly tell the compiler that a literal number is supposed to be a float by typing the letter f after the number (i.e. 1000.0f). However, when I brought my code over into VC++7.0, the compiler started giving me tons of ''convert double to float'' warnings. Has the format changed, or am I just missing something? Also, would appreciate mention of any other 6.0 -> 7.0 problems that you have encountered, and how to fix them. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Since you already append f those values definetively are float. You probably happen to use functions which expect double. Therefore the compiler gives you the warning as a hint, since the float has to be converted to double. This happens with sin or cos for example, use the float counterparts sinf and cosf.

Share this post


Link to post
Share on other sites
No, that's not the case. I'm using (for example) the DirectX function D3DXMatrixPerspectiveFovLH:

D3DXMATRIX* D3DXMatrixPerspectiveFovLH(
D3DXMATRIX* pOut,
FLOAT fovy,
FLOAT Aspect,
FLOAT zn,
FLOAT zf
);

Here is the code I'm using:

D3DXMatrixPerspectiveFovLH(&matProj, PI / 4, gD3D.GetScreenAspect(), 0.01f, 1000.0f);

My gD3D.GetScreenAspect() function returns a float. The warning I get back is:

warning C4244: 'argument' : conversion from 'const double' to 'FLOAT', possible loss of data


I am always open to feedback, positive or negative...

[edited by - Teric on April 14, 2004 10:58:47 AM]

Share this post


Link to post
Share on other sites
Yes, you might want to define two different PI constants, one double and one float. Or, you can use the D3DX_PI constant, which is defined to be a float already. You should probably also divide by 4.0f instead of 4, since I *think* that the 4 might be being promoted to a double.

Share this post


Link to post
Share on other sites
Wouldn''t 4.0f be promoted to a double as well? You can either cast the whole expression to float to shut up the compiler or turn off/ignore those warnings.

Or create a PI constant that''s a float like Aprosenf said.

Share this post


Link to post
Share on other sites
Yes, that was it. I took my PI constant (which was a double) and changed it to a float, and the warning went away. Thanks guys!

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.

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!