Why should I always enable compiler warnings?

后端 未结 20 1603
时光说笑
时光说笑 2020-11-22 00:28

I often hear that when compiling C and C++ programs I should \"always enable compiler warnings\". Why is this necessary? How do I do that?

Sometimes I also hear tha

20条回答
  •  不知归路
    2020-11-22 01:12

    You should definitely enable compiler warnings as some compilers are bad at reporting some common programming mistakes, including the following:-

    -> initialise a variable gets forgotten -> return a value from a function get missed -> the simple arguments in printf and scanf families not matching the format string a function is used without being declared beforehand, though happens in c only

    So as these functions can be detected and reported, just usually not by default; so this feature must be explicitly requested via compiler options.

提交回复
热议问题