前言
coding最好要形成一定的编程风格,一般常用的开源风格有google code style,可以使用cpplint工具检查是否符合该编程风格。
目录
1. linux系统使用过程;
2. windows系统使用过程;
注意,目前cpplint.py是基于python2的脚本,若要使用python3请按照python3改写cpplint.py。
操作
1. linux系统使用过程
1.1 安装cpplint;
$pip install cpplint
1.2 保存cpplint.py文件;
1.3 检测单个文件;
cpplint_dir$python2 cpplint.py test.cpp
1.4 检测批量文件;
根据要检测的文件编写shell脚本,然后运行即可。
注意,sh和bat适应于不同的系统,bat文件是window系统的执行文件,sh是linux系统的批处理文件。
cpplint_shell.sh实例;
#! /bin/bash echo "^@^cpplint code style check through shell====^@^" index=0 config="" pwd_path=`pwd` cpplint_path="$pwd_path/cpplint.py" echo cpplint_path=$cpplint_path src_path="$pwd_path/src" echo src_path=$src_path # add file to an array,and check file in array last # for file in `find $src_path -name "*.h" -type f` for file in `find $src_path -maxdepth 1 -type f | grep -E ".h$|.cc$|.cu$|.cpp$"` do echo file=$file echo -e "