Treat warnings as errors ?
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
I used to turn it off when developing and turn it on when doing code review and fix all warnings. Of late,, I just leave it on by default as I've got used to the cases where a warning can occur and avoid that route when developing. It's useful if it's in line with your/your company's coding standards.
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
If you have that many warnings, then that proves the point. Your code has issues, so fix them.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
I turn it on when possible (sometimes you can't avoid getting the warning), I try to watch out for them since I have experianced 'bugs' because off them
-
If you have that many warnings, then that proves the point. Your code has issues, so fix them.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
Yeah. Most of them are unused variable warnings. Actually it's a maintenance project, so hard to fix all those warnings.
-
I turn it on when possible (sometimes you can't avoid getting the warning), I try to watch out for them since I have experianced 'bugs' because off them
TDDragon wrote:
I turn it on when possible (sometimes you can't avoid getting the warning),
That's what
#pragma warning(push/pop)
and#pragma warning(disable: x)
are for, so you can turn off a specific warning for a short section of code. -
TDDragon wrote:
I turn it on when possible (sometimes you can't avoid getting the warning),
That's what
#pragma warning(push/pop)
and#pragma warning(disable: x)
are for, so you can turn off a specific warning for a short section of code.Graham Bradshaw wrote:
#pragma warning(push/pop) and #pragma warning(disable: x)
WOW ! That's great. I will look into that. Thanks
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
You could leave the option to "off" and make a habit in checking the warnings ;-)
V.
Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive -
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
I can't speak for others, but I personally always do. I do know that sometimes (especially VC6's STL code), library headers etc produce warnings, but I always think it's worth wrapping #pragma's around such situations to disable the warnings. Having code compile clean with /W4 /WX is a very useful baseline, potential breakage is instantly spotted. I have to admit I take it further as well by using Gimpel's PC Lint and Microsoft's own C++ static analysis (/analyze) tools in VC 2005 and later. Mike
-
Yeah. Most of them are unused variable warnings. Actually it's a maintenance project, so hard to fix all those warnings.
ForumExpertOnLine wrote:
Most of them are unused variable warnings
Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:
void MyFunction(int)
{
// Code here
}Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++ -
TDDragon wrote:
I turn it on when possible (sometimes you can't avoid getting the warning),
That's what
#pragma warning(push/pop)
and#pragma warning(disable: x)
are for, so you can turn off a specific warning for a short section of code.true but that's c# only I have to work in vb.net and unless I'm mistaking there is no such a 'code' in vb.net I could alter the project file as explaned here: http://www.helixoft.com/blog/archives/31[^] but then I'd rather leave them as warnings and check (and correct them if possible) them whenever one pops up
-
ForumExpertOnLine wrote:
Most of them are unused variable warnings
Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:
void MyFunction(int)
{
// Code here
}Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++I always prefer
void MyFunction(int param)
{
// Code hereUNREFEERENCED_PARAMETER(param);
}To me, that says "I made a conscious decision to ignore the variable", rather than "I forgot to use it". You also get to keep the name of the variable, which (you would hope) would include some semantic information in the name itself.
-
true but that's c# only I have to work in vb.net and unless I'm mistaking there is no such a 'code' in vb.net I could alter the project file as explaned here: http://www.helixoft.com/blog/archives/31[^] but then I'd rather leave them as warnings and check (and correct them if possible) them whenever one pops up
TDDragon wrote:
that's c# only
and C++
-
TDDragon wrote:
that's c# only
and C++
Yeah sorry forgot about that one ;P its been over 3 years since I done anything in C++ so I'm a bit rusty on that language (really should look into it again)
-
ForumExpertOnLine wrote:
Most of them are unused variable warnings
Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:
void MyFunction(int)
{
// Code here
}Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++Nice, and what about
HFONT CreateFont(int,int,int,int,int,int,int,int,int,int,int,int,int,LPCTSTR);
at least names suggest something more about the possible usage (!)2 bugs found. > recompile ... 65534 bugs found. :doh:
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
Compilers don't warn The Chuck Norris, The Chuch Norris warns them. If compilers don't fix the errors themselves, The Chuch Norris round house kicks them to 0xC0000005.
---------------------------------------------------------- Every nation state's armed forces call themselves 'Defence', makes me wonder why there are conflicts in the world.
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
No I don't, but then the only errors I get are VC6 STL warnings on the length of the names. Well, those are the only ones I get at level 3, at level 4 there are lots but it's a legacy project which is too big to sort out. :(
-
ForumExpertOnLine wrote:
Most of them are unused variable warnings
Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:
void MyFunction(int)
{
// Code here
}Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++I prefer:
void MyFunction(int /*my_arg*/)
{
// Code here
}Software Zen:
delete this;
-
ForumExpertOnLine wrote:
Most of them are unused variable warnings
Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:
void MyFunction(int)
{
// Code here
}Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++void MyFunction(int /*iMyValue*/)
{
// Code here
}at least reminds you what the variable name was
Help me! I'm turning into a grapefruit! Buzzwords!
-
Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?
We try not to have warnings (or lint issues for that matter) in our code in the first place. When they creep in (which will inevitably happen, especially during major changes), they are removed shortly afterwards. However, in my experience "Treat warnings as errors" is a great way to annoy your teammates - especically if they are less meticulous in fixing warnings.
Anna :rose: Having a bad bug day? Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"