Talking about the warning that is wrong

Copyright: https://blog.csdn.net/nicai_xiaoqinxi/article/details/91128251

Compiler warning gives the impression that people pay attention to this issue. Moreover think, compiler warnings just to look overly cautious person. In fact why there is a warning that a problem in itself worth thinking about?

  Yesterday, the new colleagues soon prepare a debugging function on the line, but also how to debug it out. Then just drink water, he saw hundreds of warnings. And he said something about you or compiler warnings it. He said with a look of anxiety: no time to get ah? ! Function going on the line to help me find. He also said that if it is a very serious warning, causes a compilation error, it can be compiled.

  Watching some frustration, this very disagree. He looked anxious expression, to solve the problem first.
Browse the code into the discernment to see there is a warning, this is the use '==' to turn this assignment into an equality comparison.meaning 使用'=='将该赋值转换为相等比较. Locate the appropriate code:

if (isEmpty = true) {
...
}

  Colleagues looked at the code, I know where the problem of. Good luck tonight, you eat chicken. Now solve the problem, you should solve what you those 编译警告, these warnings may be hidden inside a lot of bug.

  for example? Colleagues look studious look. You see there are many programs 变量未使用warning, you should clean up it. Because the variable may not really use, but you may be using the wrong lead to other variables. The latter may bring the consequences of your program just to run, but a fatal error may occur in some cases.

  As I turned around ready to work, he asked, that I tune it 编译警告promoted 编译错误could it not?

  It can be, but the situation should be divided. If you are new to write a program you can do so, if it is already written most of a project, if you do so may result in disruptive consequences, making it difficult to control. Because the compiler can easily compile compiler warnings into errors, but you can not easily solve it.

  How should I do?
  Come on, step by step. Added warning you to solve it in the time of writing, and the old warning should be carefully addressed. For the GCC compiler you can use -Werrorparameters to make the warning can not be ignored. Let too is MSVC compiler, you can change the settings of the project. In addition to IDE has set up how the compiler warnings as compilation errors.

Guess you like

Origin blog.csdn.net/nicai_xiaoqinxi/article/details/91128251