Disabling warnings on visual c++ 2008

Started by
16 comments, last by Cornstalks 11 years, 10 months ago
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;
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
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.
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)

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

SiCrane means:
bool DrawDebugInfo = !!lua_tonumber(LuaState, 1);


Personally, I find that warning is always spurious so I just disable it.
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.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

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.

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

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.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement