Can I treat a specific warning as an error?

前端 未结 4 1012
醉梦人生
醉梦人生 2020-12-06 16:36

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;
}
         


        
4条回答
  •  余生分开走
    2020-12-06 17:11

    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)).

提交回复
热议问题