What are the go-to tools for finding errors in C code?

191 views Asked by At

It might be either static or dynamic analysis, preferably free.

1

There are 1 answers

2
dom0 On BEST ANSWER
  • cppcheck checks both C and C++ code and finds many errors.

  • Valgrind is a tool for runtime analysis, but I mention it anyway. It is extremely useful for tracking memory errors like uninitialized usage or leaks.

  • Also, activate ALL warnings your compiler has (GCC and clang: -Wall -Wpedantic -Wextra), which often reveals useful info.

  • Note: clang sometimes generates much better warnings/errors than GCC

  • To find logic errors, however, testing is required. Testing is required anyway, something that is not tested is per definition broken, as you cannot assume it works.
    Wikipedia has a list of C unit testing software.