Any Tools to Catch Silly Mistakes in C Code?

后端 未结 11 2642
臣服心动
臣服心动 2021-02-20 08:11

I had a nasty typo that wasted my time and my colleague\'s time, it was something like this:

for (i = 0; i < blah; i++); // <- I had a semi-colon here, tha         


        
11条回答
  •  时光说笑
    2021-02-20 08:33

    I would suggest seeing if you have the ability to enforce MISRA standards. They were written with great thought and many rules that are simple for a compiler to check. For example, A rule I use requires all NOP commands have their own line. This means when you put a ; on the end of a loop statement it will through an error saying that it is not on it's own line.

提交回复
热议问题