Jump to content
  • Advertisement
Sign in to follow this  
Gage64

Disabling a warning in a header file - doesn't work

This topic is 3639 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 have a header file that I include in almost every other file. (Right now it only contains a few typedefs so it's not like a "master" header that includes all other headers.) There is a warning that I get fairly often and that I'd like to disable (4244 - conversion from int to float), so I added a pragma to this header file. However, I still got the warning. I made sure that I'm not restoring it using the "default" pragma in any of my other files. I placed the pragma at the top of the file, but after the include guards. I then tried placing it outside the include guards and the warning went away, but I don't understand why this matters. If I place it inside the include guards, shouldn't that just mean that it will appear exactly once in the .cpp file? (even if the header is included several times through other headers.) Could someone please explain this behavior?

Share this post


Link to post
Share on other sites
Advertisement
A "conversion from int to float" error has nothing to do with include problems with header files. Which exact line number is that error referring to?

Somewhere somehow an integer value is being converted to a float data type. It could hardly cause problems but you might want to do something about it. If you really meant it to happen, do a static_cast on it.

Share this post


Link to post
Share on other sites
The simplest solution is to turn the warning off in the project settings if you don't ever want to see it.

To track down that weird behaviour you'll want to see the result of the preprocessor for a file that generates the error unexpectedly (use the /P command line option). Looking at that should make the problem obvious.

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!