Ubuntu安装使用google代码规范工具cpplint

来源:互联网 发布:人工智能用什么语言写 编辑:程序博客网 时间:2024/05/29 16:45

cpplint 1.3.0下载链接: https://pypi.python.org/pypi/cpplint

此工具是一个C++代码样式检查器,遵循google的代码规范(英文原版、中文译版)


1.  cpplint安装

$ pip install cpplint

2.  cpplint运行

$ cpplint [OPTIONS] files

3.  cpplint帮助

$ cpplint --help

4.  cpplint测试

            #include <iostream>            using namespace std;            int main(){                cout<<"hello world!"<<endl;                                return 0;            }

5.  终端错误显示

6.  修改如下

  • 未写copyright
  • using namespace std; 修改为 using::
  • int main(){ 修改为 int main() { 大括号前空格问题
            /*            # Copyright (c) 2017 Yz L. All rights reserved.            */            #include <iostream>                        int main() {            std::cout <<"hello world!"<<std::endl;            return 0;            }

7.   终端显示

原创粉丝点击