Home » Questions » Computers [ Ask a new question ]

Choosing a static code analysis tool [closed]

Choosing a static code analysis tool [closed]

"Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.












Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 5 years ago.





Improve this question





I'm working on a project where I'm coding in C in a UNIX environment. I've been using the lint tool to check my source code. Lint has been around a long time (since 1979), can anyone suggest a more recent code analysis tool I could use ? Preferably a tool that is free."

Asked by: Guest | Views: 334
Total answers/comments: 4
Guest [Entry]

"Don't overlook the compiler itself. Read the compiler's documentation and find all the warnings and errors it can provide, and then enable as many as make sense for you.
Also make sure to tell your compiler to treat warnings like errors so you're forced to fix them right away (-Werror on gcc).
By the way, don't be fooled -Wall on gcc does not enable all warnings.
You may want to check valgrind (free!) — it ""automatically detect[s] many memory management and threading bugs, and profile[s] your programs in detail."" It isn't a static checker, but it's a great tool!"
Guest [Entry]

"For C code, you definitely should definitely use Flexelint. I used it for nearly 15 years and swear by it. One of the really great features it has is that warnings can be selectively turned off and on via comments in the code (""/* lint -e123*/""). This turned out to be a powerful documentation tool when you wanted to something out of the ordinary. ""I am turning off warning X, therefore, there is some good reason I'm doing X.""

For anybody into interesting C/C++ questions, look at some of their examples on their site and see if you can figure out the bugs without looking at the hints."
Guest [Entry]

"I've heard good things about clang static analyzer, which IIRC uses LLVM as it's backend. If that's implemented on your platform, that might be a good choice.

From what I understand, it does a bit more than just syntax analysis. ""Automatic Bug Finding"", for instance."
Guest [Entry]

"You can use cppcheck. It is an easy to use static code analysis tool.For example:
cppcheck --enable=all .
will check all C/C++ files under the current folder."