static analysis of C/C++ code
Clone or download
Latest commit 6ceab1f Sep 23, 2018
Failed to load latest commit information.
Cppcheck.xcodeproj Fix xcode project file Nov 23, 2015
addons misra: fix fp for rule 3.1 Sep 8, 2018
cfg wxwidgets.cfg: Added support for some wxObject functions. Sep 21, 2018
cli cmdlineparser: Stop processing in case an invalid path for --includes… Sep 4, 2018
cmake Minor Cleanups (#1321) Jul 23, 2018
democlient Democlient: Jul 17, 2016
externals Bump simplecpp May 14, 2018
gui triage: set error line properly Sep 1, 2018
htmlreport Improve Python code Jun 4, 2017
lib New fix for #8771. Remove line attribute in <location> when there is … Sep 23, 2018
man Support floats in valid config (#1297) Jul 15, 2018
platforms Platforms: Add arm32 and arm64 platform files (#1128) Mar 21, 2018
rules Fix a typo in a message for a rule (#1181) Apr 19, 2018
samples Make warning disappear (#957) Sep 8, 2017
snap Fix permissions of certain non-executable files (#1083) Feb 9, 2018
test Temporarily comment out the followVariable() handling Sep 23, 2018
tools Missing return value in git-pre-commit-cppcheck (#1382) Sep 21, 2018
triage Improve Python code Jun 5, 2017
win_installer Windows Installer: Added qwindowsvistastyle.dll Jun 25, 2018
.codacy.yml .codacy.yml: Ignore *.cpp files in addons/test too Aug 22, 2018
.gitignore Minor Cleanups (#1321) Jul 23, 2018
.mailmap Revert "Revert "Add a .mailmap file."" Oct 4, 2013
.travis.yml addons/ Add MSC30-C: Do not use rand() (#1348) Aug 24, 2018
.travis_llvmcheck_suppressions travis: update commits of the clang/llvm repo we are checking during CI May 10, 2018
.travis_suppressions Initial check for recommending algorithms (#1352) Sep 19, 2018
AUTHORS Updated AUTHORS Jun 10, 2018
CMakeLists.txt Minor Cleanups (#1321) Jul 23, 2018
COPYING Licensing: Using the GPL 3 license Oct 26, 2008
Makefile checkstl: remove uused variable 'beginCondTok' Sep 22, 2018
appveyor.yml appveyor: go back from vs2017 to vs2015 since the path worked better Apr 9, 2018
benchmarks.txt benchmarks.txt: suggest that cryptopp is used (c++ code with plenty o… May 11, 2018
build-pcre.txt Updated/Improved several readme files Nov 6, 2015
build.bat batch files: switch to the batch file directory before doing anything… Sep 29, 2012
console_common.pri pro and pri files: remove unneeded empty lines, use spaces for consis… Oct 12, 2012
cppcheck-errors.rng #8611 Rename xmlV2.rng. Renaming it to cppcheck-errors.rng (#1278) Jun 6, 2018
cppcheck.cbp Removed ExecutionPath Jul 23, 2015
cppcheck.cppcheck Add cppcheck.cppcheck build dir Feb 23, 2018
cppcheck.sln Updated Visual Studio solution to VS2017. May 14, 2017
createrelease updated createrelease Mar 31, 2018
doxyfile Update doxyfile (#1314) Jul 20, 2018
generate_coverage_report Adjust options for lcov/genhtml to unmangled symbols and HTML frames Feb 2, 2016 Added a document. Sep 6, 2018 Remove some more cxx11emu.h references Apr 10, 2018
readme.txt Remove some more cxx11emu.h references Apr 10, 2018
runastyle Updated runastyle scripts Jun 20, 2018
runastyle.bat Updated runastyle scripts Jun 20, 2018 webreport: skip simian Dec 26, 2017


Linux Build Status Windows Build Status Coverity Scan Build Status
Linux Build Status Windows Build Status Coverity Scan Build Status


If you find Cppcheck useful for you, feel free to make a donation.


About the name

The original name of this program was "C++check", but it was later changed to "Cppcheck".

Despite the name, Cppcheck is designed for both C and C++.


A manual is available online.


Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2013 / GCC 4.6 then it will work.

To build the GUI, you need Qt.

When building the command line tool, PCRE is optional. It is used if you build with rules.

There are multiple compilation choices:

  • qmake - cross platform build tool
  • cmake - cross platform build tool
  • Windows: Visual Studio (VS 2010 and above)
  • Windows: Qt Creator + mingw
  • gnu make
  • g++ 4.6 (or later)
  • clang++


You can use the gui/ file to build the GUI.

cd gui

Visual Studio

Use the cppcheck.sln file. The file is configured for Visual Studio 2015, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.

To compile with rules, select "Release-PCRE" or "Debug-PCRE" configuration. pcre.lib (pcre64.lib for x64 builds) and pcre.h are expected to be in /externals then.

Qt Creator + MinGW

The PCRE dll is needed to build the CLI. It can be downloaded here:

GNU make

Simple, unoptimized build (no dependencies):


The recommended release build is:

make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"


  1. SRCDIR=build
    Python is used to optimise cppcheck

  2. CFGDIR=cfg
    Specify folder where .cfg files are found

  3. HAVE_RULES=yes
    Enable rules (PCRE is required if this is used)

  4. CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" Enables most compiler optimizations, disables cppcheck-internal debugging code and enables basic compiler warnings.

g++ (for experts)

If you just want to build Cppcheck without dependencies then you can use this command:

g++ -o cppcheck -std=c++11 -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp

If you want to use --rule and --rule-file then dependencies are needed:

g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp


mingw32-make LDFLAGS=-lshlwapi

Other Compiler/IDE

  1. Create a empty project file / makefile.
  2. Add all cpp files in the cppcheck cli and lib folders to the project file / makefile.
  3. Add all cpp files in the externals folders to the project file / makefile.
  4. Compile.

Cross compiling Win32 (CLI) version of Cppcheck in Linux

sudo apt-get install mingw32
make CXX=i586-mingw32msvc-g++ LDFLAGS="-lshlwapi" RDYNAMIC=""
mv cppcheck cppcheck.exe