Cppcheck is a
static code analysis
In computer science, static program analysis (also known as static analysis or static simulation) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs duri ...
tool for the
C and
C++ programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
s. It is a versatile tool that can check non-standard code. The creator and lead developer is Daniel Marjamäki.
Cppcheck is
Open-core software, with its open-source core code under the
GNU General Public License
The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
.
Features
Cppcheck supports a wide variety of static checks that may not be covered by the compiler itself. These checks are static analysis checks that can be performed at a source code level. The program is directed towards static analysis checks that are rigorous, rather than
heuristic
A heuristic or heuristic technique (''problem solving'', '' mental shortcut'', ''rule of thumb'') is any approach to problem solving that employs a pragmatic method that is not fully optimized, perfected, or rationalized, but is nevertheless ...
in nature.
Some of the checks that are supported include:
*
Automatic variable
In computer programming, an automatic variable is a local variable which is allocated and deallocated automatically when program flow enters and leaves the variable's scope. The scope is the lexical context, particularly the function or block in ...
checking
*
Bounds checking
In computer programming, bounds checking is any method of detecting whether a variable is within some bounds before it is used. It is usually used to ensure that a number fits into a given type (range checking), or that a variable being used as ...
for array overruns
*
Classes checking (e.g. unused functions, variable initialization and memory duplication)
* Usage of
deprecated
Deprecation is the discouragement of use of something human-made, such as a term, feature, design, or practice. Typically something is deprecated because it is claimed to be inferior compared to other options available.
Something may be deprec ...
or superseded functions according to
Open Group
* Exception safety checking, for example usage of memory allocation and destructor checks
*
Memory leak
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in a way that memory which is no longer needed is not released. A memory leak may also happen when an objec ...
s, e.g. due to lost scope without deallocation
*
Resource leak
In computer science, a resource leak is a particular type of resource consumption by a computer program where the program does not release resources it has acquired. This condition is normally the result of a bug in a program. Typical resource lea ...
s, e.g. due to forgetting to close a file handle
* Invalid usage of
Standard Template Library
The Standard Template Library (STL) is a software library originally designed by Alexander Stepanov for the C++ programming language that influenced many parts of the C++ Standard Library. It provides four components called ''algorithms'', '' ...
functions and
idiom
An idiom is a phrase or expression that largely or exclusively carries a Literal and figurative language, figurative or non-literal meaning (linguistic), meaning, rather than making any literal sense. Categorized as formulaic speech, formulaic ...
s
*
Dead code elimination
In compiler theory, dead-code elimination (DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove dead code (code that does not affect the program results). Removing such code has several benefits: i ...
using unusedFunction option
* Miscellaneous stylistic and performance errors
As with many analysis programs, there are many unusual cases of programming idioms that may be acceptable in particular target cases or outside of the programmer's scope for source code correction. A study conducted in March 2009 identified several areas where false positives were found by Cppcheck, but did not specify the program version examined.
Cppcheck has been identified for use in systems such as
CERN
The European Organization for Nuclear Research, known as CERN (; ; ), is an intergovernmental organization that operates the largest particle physics laboratory in the world. Established in 1954, it is based in Meyrin, western suburb of Gene ...
s 4DSOFT meta analysis package,
for code verification in high energy particle detector readout devices,
system monitoring software for radio telescopes as well as in error analysis of large projects, such as
OpenOffice.org
OpenOffice.org (OOo), commonly known as OpenOffice, is a discontinued open-source office suite. Active successor projects include LibreOffice (the most actively developed) and Collabora Online, with Apache OpenOffice being considered mostly d ...
and the
Debian
Debian () is a free and open-source software, free and open source Linux distribution, developed by the Debian Project, which was established by Ian Murdock in August 1993. Debian is one of the oldest operating systems based on the Linux kerne ...
archive.
Development
The project is actively under development
[Cppcheck on Github](_blank)
/ref> and is actively maintained in different distributions.
/ref>[FreeBSD port](_blank)
/ref> It has found valid bugs in a number of popular projects such as the Linux kernel
The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
and MPlayer
MPlayer is a free and open-source media player software application. It is available for Linux, OS X and Microsoft Windows. Versions for OS/2, Syllable Desktop, Syllable, AmigaOS, MorphOS and AROS Research Operating System are also available. A ...
.
Plugins
Plugins for the following IDEs or text editors
A text editor is a type of computer program that edits plain text. An example of such program is "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be used to ...
exist
* CLion
* Code::Blocks - integrated.
* CodeLite - integrated.
* Eclipse
An eclipse is an astronomical event which occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ...
* Emacs
Emacs (), originally named EMACS (an acronym for "Editor Macros"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
* gedit
* Hudson
Hudson may refer to:
People
* Hudson (given name)
* Hudson (surname)
* Hudson (footballer, born 1986), Hudson Fernando Tobias de Carvalho, Brazilian football right-back
* Hudson (footballer, born 1988), Hudson Rodrigues dos Santos, Brazilian f ...
* Jenkins
* Kate Kate may refer to:
People and fictional characters
* Kate (given name), a list of people and fictional characters with the given name or nickname
* Gyula Káté (born 1982), Hungarian amateur boxer
* Lauren Kate (born 1981), American author o ...
* KDevelop
* Qt Creator
Qt Creator is a cross-platform C++, JavaScript, Python and QML integrated development environment (IDE) which simplifies GUI application development. It is part of the SDK for the Qt GUI application development framework and uses the Q ...
* Sublime Text
* Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
* Yasca
See also
* List of tools for static code analysis
References
External links
* {{sourceforge, cppcheck
Cross-platform free software
Free software programmed in C++
Free software testing tools
Software using the GNU General Public License
Static program analysis tools