Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ code analysis tools

I'm currently in the process of learning C++, and because I'm still learning, I keep making mistakes.
With a language as permissive as C++, it often takes a long time to figure out exactly what's wrong -- because the compiler lets me get away with a lot. I realize that this flexibility is one of C++'s major strengths, but it makes it difficult to learn the basic language.
Is there some tool I can use to analyze my code and make suggestions based on best practices or just sensible coding? Preferably as an Eclipse plugin or linux application.

like image 355
Whatsit Avatar asked Feb 13 '09 16:02

Whatsit


People also ask

What is code analysis tool?

Source code analysis tools, also known as Static Application Security Testing (SAST) Tools, can help analyze source code or compiled versions of code to help find security flaws. SAST tools can be added into your IDE. Such tools can help you detect issues during software development.

Which is a type of C C++ static code analysis tool?

Cppcheck is a static analysis tool for C/C++ code. It provides unique code analysis to detect bugs and focuses on detecting undefined behaviour and dangerous coding constructs.

What is a SAST tool?

Static Application Security Testing (SAST) is a frequently used Application Security (AppSec) tool, which scans an application's source, binary, or byte code. A white-box testing tool, it identifies the root cause of vulnerabilities and helps remediate the underlying security flaws.

Which of the following tools are used for static code analysis?

SonarQube is one of the more popular static code analysis tools out there. It is an open-source platform for continuous inspection of code quality and performs automatic reviews via static code analysis. In addition, it can detect and report bugs, code smells, and numerous other security vulnerabilities.


2 Answers

Enable maximum compiler warnings (that's the -Wall option if you're using the Gnu compiler).

'Lint' is the archetypical static analysis tool.

valgrind is a good run-time analyzer.

like image 118
ChrisW Avatar answered Sep 29 '22 16:09

ChrisW


I think you'd better have some lectures about good practices and why they are good. That should help you more than a code analysis tool (in the beginning at least).

I suggest you read the series of Effective C++ and **Effective STL books, at least. See alsot The Definitive C++ Book Guide and List

like image 42
Klaim Avatar answered Sep 29 '22 15:09

Klaim