Why should I always enable compiler warnings?

后端 未结 20 1570
时光说笑
时光说笑 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:01

    The compiler warnings in C++ is very useful for some reasons.

    1 - It permit to show you where you can have made a mistake who can impact the final result of your operations. For example if you didn't initialize a variable or if you put "=" instead of "==" ( there are just examples )

    2 - It permits also to show you where your code is not conform to the standard of the c++. It's useful because if the code is conform to the actual standard it will be easy to move the code into an other plateform for example.

    In general, the warnings are very useful to show you where you have mistakes in your code who can affect the result of your algorithm or prevent some error when the user will use your program.

提交回复
热议问题