关闭

利用CCCC和CppCheck对C++代码进行检查并和Hudson集成

标签: hudsonc++reportservercommandbuffer
2728人阅读 评论(1) 收藏 举报
分类:

CCCC - a code counter for C and C++

A program to analyse C and C++ source code and report on some simple software metrics.

CCCC which stands for C and C++ Code Counter is a source code analysis tool for C and C++. It calculates metrics for the code, outputs data in a handy HTML format and even colours dangerous functions.

CCCC can be downloaded for free from http://cccc.sourceforge.net/.

Download and Install

Download from the SourceForge site (I got cccc-3.1.4.tar.gz) and extract the files. Change to the newly created directory (in my case cccc-3.1.4) and run

[root@Server cccc-3.1.4]# ./build_posixgcc.sh

[root@Server cccc-3.1.4]# make install

In the cccc directory there should be a cccc executable which can be copied to a directory in your $PATH. Generally the cccc executable is copied to /usr/local/bin/ as default.

 

Cppcheck - A tool for static C/C++ code analysis

Static analysis of C/C++ code. Checks for: memory leaks, mismatching allocation-deallocation, buffer overrun, and many more. The goal is 0% false positives.

Download and Install

Download for free from http://sourceforge.net/projects/cppcheck/ (I got cppcheck-1.30.tar.gz) and extract the files. Change to the newly created directory (in my case cppcheck-1.30) and run

[root@Server cppcheck-1.30]# make

[root@Server cppcheck-1.30]# make install

There should be a cppcheck executable which can be copied to a directory in your $PATH. Generally the cppcheck executable is copied to /usr/bin/ as default. 

 

Build -- Execute Shell in Hudson

Command 1

# change directory and compile the client source codes

cd ./client/src

make clean

make

Command 2

#change directory and using cccc for code analysis

cd ./client/src

/usr/local/bin/cccc --outdir=./cccc/ ./client/*.* ./interface/*.*

Command 3

# using cppcheck for code analysis

/usr/bin/cppcheck --xml ./client/src 2> ./client/src/cppcheck-result.xml

 

Post-build Actions

Publish CCCC report

Main XML report file path ./client/src/cccc/cccc.xml

Publish Cppcheck results

Cppcheck report XMLs **/cppcheck-result.xml

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:36330次
    • 积分:544
    • 等级:
    • 排名:千里之外
    • 原创:18篇
    • 转载:0篇
    • 译文:0篇
    • 评论:3条
    文章分类
    最新评论