The following is a simplified version of a pattern I sometimes see in my students' code:
bool foobar(int a, int b)
{
if (a < b) return true;
}
The real code is more complicated, of course. Visual Studio reports a warning C4715 (not all control paths return a value), and I would like to treat all warnings C4715 as errors. Is that possible?
Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.
An error in MySQL informs you that you actually did something wrong, describes the problem, and stops the process or query. A warning will not stop anything, but is there to tell you that something happened that is not expected (or there may be a potential issue) and it's not critical enough to terminate.
They are not errors from the viewpoint of a programming language, but they may be software bugs. However, many compilers can be customized so that their warnings don't stop the compilation process. Warnings must not be ignored. You'd better fix every possible error before starting software testing.
This should do the trick: #pragma warning (error: 4715)
.
Or the /we4715
command line option (see /w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level) (courtesy of Tom Sigerdas)).
/we4715
works for me.
In Visual Studio 2013 anyway, it is in the UI under Project Settings -> Configuration Properties -> C/C++ -> *Advanced *-> Treat Specific Warnings as Errors. Add "4715".
Docs: http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
(Please note that this page lists the wrong UI property for VS2013.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With