水木-软件测试-求推荐代码静态分析工具(c,c++代码),Cppcheck - C/C++代码的静态分析工具...

Cppcheck

Linux Build Status

Windows Build Status

Coverity Scan Build Status

68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64616e6d61722f637070636865636b2f6d61737465722e7376673f6c6162656c3d4c696e75782532306275696c64

68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f64616e6d61722f637070636865636b2f6d61737465722e7376673f6c6162656c3d57696e646f77732532306275696c64

68747470733a2f2f696d672e736869656c64732e696f2f636f7665726974792f7363616e2f3531322e737667

Donations

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

687474703a2f2f706c65646769652e636f6d2f63616d706169676e732f343132372e706e67

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 2013 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:

SRCDIR=build

Python is used to optimise cppcheck

CFGDIR=cfg

Specify folder where .cfg files are found

HAVE_RULES=yes

Enable rules (PCRE is required if this is used)

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

Create a empty project file / makefile.

Add all cpp files in the cppcheck cli and lib folders to the project file / makefile.

Add all cpp files in the externals folders to the project file / makefile.

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值