• Advertisement
Sign in to follow this  

Disabling warnings on visual c++ 2008

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

Is there a way to do it? Or at least to separate them from the error messages? It's not that I have a problem with warnings(I just ignore them, like any other programmer), but the thing is that usually when my compilation succeeds, I get few warnings(about 10 or 20, sometimes less), but when it fails, each error produces more than 100 warnings, and I have to scan the entire list to find the error(which is the root of the problem).

Share this post


Link to post
Share on other sites
Advertisement
When you look at the error list, there will be three buttons at the top for errors, warnings and messages. Just click the warning button and it will toggle warnings.

Share this post


Link to post
Share on other sites
Quote:

I just ignore them, like any other programmer

Not all programmers ignore warnings. I compile all my programs on the highest warning level, usually with few or no warnings disabled. For example, the project I had open right now only disabled C4800, which is "forcing value to bool 'true' or 'false' (performance warning). It is possible to have no warnings in large programs. Sometimes you may need to disable specific warnings in the overall codebase or disable them in very small sections. Try googling the error number if you want to find out how to fix the code, rather than simply disabling the warning.

Share this post


Link to post
Share on other sites
you can disable them with pragma's, i.e.

#pragma warning(disable:4244)

where the number is the warning to disable. Having said that, warnings are problems with code and you should try to fix the code that causes the warning rather than disabling it. I agree with rip-off on this one. Turn the warning level to max, and fix the code!

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
When you look at the error list, there will be three buttons at the top for errors, warnings and messages. Just click the warning button and it will toggle warnings.


Can't find it:
Free Image Hosting at www.ImageShack.us

Share this post


Link to post
Share on other sites
Quote:
Original post by RobTheBloke
#pragma warning(disable:4244)


It's probably best to push / pop the warning stack :


#pragma warning(push)
#pragma warning(disable:4244)
// do something slightly dodgy, that the compiler would normally complain about
#pragma warning(pop)



Share this post


Link to post
Share on other sites
Quote:
Original post by someboddy
It's not that I have a problem with warnings(I just ignore them, like any other programmer)


I wish my professors felt this way. They always seem to feel the need to take points off for each instance of each warning ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
C4800, which is "forcing value to bool 'true' or 'false' (performance warning).


How would you correctly fix such a warning? My project's full of them, from my Lua binding code.

Share this post


Link to post
Share on other sites
The last professional game project I worked on (AAA title) was built for multiple platforms, with warnings-as-errors on all of them. We also ran Lint on all the code, although I'm not sure we fixed quite all of those before ship.
Quote:
Original post by deadstar
Quote:
Original post by rip-off
C4800, which is "forcing value to bool 'true' or 'false' (performance warning).


How would you correctly fix such a warning? My project's full of them, from my Lua binding code.
Compare to 0.
Instead of: bool x = (bool) integerVal;
Use: bool x = integerVal != 0;

Share this post


Link to post
Share on other sites
Quote:
Original post by deadstar
Quote:
Original post by rip-off
C4800, which is "forcing value to bool 'true' or 'false' (performance warning).


How would you correctly fix such a warning? My project's full of them, from my Lua binding code.

Depends on what you mean by fix. If you mean just shut up the compiler without using a pragma to disable the warning then you could use !!expr.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Quote:
Original post by deadstar
Quote:
Original post by rip-off
C4800, which is "forcing value to bool 'true' or 'false' (performance warning).


How would you correctly fix such a warning? My project's full of them, from my Lua binding code.

Depends on what you mean by fix. If you mean just shut up the compiler without using a pragma to disable the warning then you could use !!expr.


I'm not sure I get what you mean by !!expr, this sounds new to me.

The crime:

bool DrawDebugInfo = (bool)lua_tonumber(LuaState, 1);


The sentence:

warning C4800: 'lua_Number' : forcing value to bool 'true' or 'false' (performance warning)

Share this post


Link to post
Share on other sites
SiCrane means:

bool DrawDebugInfo = !!lua_tonumber(LuaState, 1);


Personally, I find that warning is always spurious so I just disable it.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
SiCrane means:

bool DrawDebugInfo = !!lua_tonumber(LuaState, 1);


Personally, I find that warning is always spurious so I just disable it.


Thanks, I finally found the right term to Google for (Double negation?)

Looks odd, but I thank you both very much, that warning is starting to get irritating.

Share this post


Link to post
Share on other sites
Quote:
Original post by someboddy
(I just ignore them, like any other programmer)


I usually disable them, too. They are just annoying, and for many bugs, the program will anyways only crash every 6th or 7th time, which is totally acceptable as I can tell my customers that it's the operating systems fault. I hear that disabling warnings is standard in many industries to improve productivity, for example in the car manufacturing industry, yay.


No, I was just kidding. No offense ;)

Real Programmers have their warnings always enabled, except they have to work around compiler bugs or participate to a obfuscation contest, then they disable a warning locally. It's just wise to do enable warnings; actually, producing warning messages is often harder for compiler writers than just kicking off an error message, because sometimes they warn about code that is correct according to standards, but which actually points out something the programmer did not intend; appreciate their support! And not reading warnings and solving the problem can mean, e.g., that 6 months later you end up in weeks of debugging sessions, because the rare circumstance under which your code runs fine, has vanished. There are 1000s of reasons not to ignore them.

Share this post


Link to post
Share on other sites

1>i:\new folder (2)\users\wheatly\documents\visual studio 2008\projects\irrationalengine\irrenginev2\irrmath.h(56) : warning C4172: returning address of local variable or temporary


since i use local variables a lot (a lot of code I've seen uses local variables and it's the prefered method in class functions. there's tongs of these errors what should i do (rather then start a new thread i would hijack this one :-P

Share this post


Link to post
Share on other sites

since i use local variables a lot (a lot of code I've seen uses local variables and it's the prefered method in class functions. there's tongs of these errors what should i do

You should stop returning the address of local variables.


(rather then start a new thread i would hijack this one :-P

Wrong idea, you should start a new thread. I won't be replying to this thread anymore, it's 3 years old. Let it die in peace. Start your own thread.

Share this post


Link to post
Share on other sites

This topic is 2083 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.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement