C++ Python C Makefile Shell CMake Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Cppcheck.xcodeproj Fix xcode project file Nov 23, 2015
addons Misra.py fix multiple file processing (#1332) Aug 9, 2018
cfg wxwidgets.cfg: Added support for wxString::Strip(). Aug 10, 2018
cli Renamed --debug to --debug-simplified Aug 5, 2018
cmake Minor Cleanups (#1321) Jul 23, 2018
democlient Democlient: Jul 17, 2016
externals Bump simplecpp May 14, 2018
gui Fix Cppcheck warning Aug 11, 2018
htmlreport Improve Python code Jun 4, 2017
lib Uninitalized variables: Fixed false positive Aug 15, 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 Uninitalized variables: Fixed false positive Aug 15, 2018
tools daca2-report: use 'diff' tool Aug 14, 2018
triage Improve Python code Jun 5, 2017
win_installer Windows Installer: Added qwindowsvistastyle.dll Jun 25, 2018
.codacy.yml Codacy: Exclude more test files which contain errors by intention (#1106 Mar 7, 2018
.gitignore Minor Cleanups (#1321) Jul 23, 2018
.mailmap Revert "Revert "Add a .mailmap file."" Oct 4, 2013
.travis.yml travis: update clang and llvm repo hashes. Aug 12, 2018
.travis_llvmcheck_suppressions travis: update commits of the clang/llvm repo we are checking during CI May 10, 2018
.travis_suppressions travis: remove redundant suppressions May 12, 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 gui: fix 2 findings by cppcheck Aug 9, 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
readme.md 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.sh webreport: skip simian Dec 26, 2017

readme.md

Cppcheck

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

Donations

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

Donate

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++.

Manual

A manual is available online.

Compiling

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++

qmake

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

cd gui
qmake
make

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: http://software-download.name/pcre-library-windows/

GNU make

Simple, unoptimized build (no dependencies):

make

The recommended release build is:

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

Flags:

  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

MinGW

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

Webpage

http://cppcheck.sourceforge.net/