IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> Linux PC-lint plus 静态代码检查 -> 正文阅读

[C++知识库]Linux PC-lint plus 静态代码检查

Linux PC-lint plus 静态代码检查

步骤

  • 参考

    Pub: 我家有只小虎牙 2020-11-20 14:50:40

    Url: https://blog.csdn.net/zj82448191/article/details/109847973

  • 准备

    • 1)安装python
      sudo apt install python3
      curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py   # 下载安装脚本
      sudo python get-pip.py
      pip3 --version
      pip3 install regex
      pip3 install pyyaml
      
    • 2)下载 PC-lint plus
      git clone https://hub.fastgit.org/shinyathena/PCLint_Plus.git
      cp -rf ./pclintplus1.2.1/ /home/my/tools
      
      1. 在linux下设置环境变量PATH,将可执行文件pclp64_linux添加到环境变量PATH中。
      vi ?/.bashrc
      export PATH=$PATH:/home/my/tools/pclintplus1.2.1  // 添加这一行,其中 /home/my/tools/pclintplus1.2.1 是你自己的路径
      
  • 步骤

    // 生成 co-gcc.lnt
    cd /home/my/tools/pclintplus1.2.1/config
    python3 pclp_config.py --compiler=gcc --config-output-lnt-file=co-gcc.lnt --config-output-header-file=co-gcc.h --generate-compiler-config
    
    // 编译 imposter
    cd /home/my/tools/pclintplus1.2.1/config
    gcc -o imposter imposter.c
    
    // 生成 hello.commands
    export IMPOSTER_LOG=hello.commands
    cd /mnt/d/work/src // Makefile 所在目录
    make -e CC=/home/my/tools/pclintplus1.2.1/config/imposter  AR=/home/my/tools/pclintplus1.2.1/config/imposter
    
    // 生成 hello.lnt 
    cd /mnt/d/work/src/main
    python3 /home/my/tools/pclintplus1.2.1/config/pclp_config.py --compiler=gcc --imposter-file=hello.commands --config-output-lnt-file=hello.lnt --generate-project-config
    
    // 修改 hello.lnt, 添加 arm-linux-gnueabihf-gcc 头文件目录
    cp hello.lnt hello.lnt.backup
    vim hello.lnt
    
    -env_push
    -i"//usr/local/arm-linux-compiler/arm-linux-gnueabihf/libc/usr/include"
    -i"//usr/local/arm-linux-compiler/arm-linux-gnueabihf/libc/usr/lib/include"
    -i"//usr/local/arm-linux-compiler/arm-linux-gnueabihf/include/c++/4.9.3"
    -i"//usr/local/arm-linux-compiler/arm-linux-gnueabihf/include/c++/4.9.3/arm-linux-gnueabihf"
    -i"//usr/local/arm-linux-compiler/lib/gcc/arm-linux-gnueabihf/4.9.3/include"
    -i"/mnt/d/work/work/system/inc"
    -fcu
    "src/*.c"  // 这里修改为 lint 所有 .c 文件
    -env_pop
    
    // 静态代码检查
    cp /home/my/tools/pclintplus1.2.1/config/co-* ./
    pclp64_linux co-gcc.lnt hello.lnt  > warning-out.c
    

PC-Lint PLus 错误号

  • PC-Lint Plus Manual

    RangeDescriptionWarning Level
    1-199C Syntax Errors1
    200-299Internal Errors1
    300-399Fatal Errors1
    400-699C Warnings2
    700-899C Informational3
    900-999C Elective Notes4
    1000-1199C++ Syntax Errors1
    1200-1299Internal Errors1
    1300-1399C++ Fatal Errors1
    1400-1699C++ Warnings2
    1700-1899C++ Informational3
    1900-1999C++ Elective Notes4
    2000-2199C Syntax Errors1
    2200-2399Reserved
    2400-2699C Warnings2
    2700-2899C Informational3
    2900-2999C Elective Notes4
    3000-3199C++ Syntax Errors1
    3200-3399Reserved
    3400-3699C++ Warnings2
    3700-3899C++ Informational3
    3900-3999C++ Elective Notes4
    4000-5999C and C++ Errors1
    6000-6999Reserved
    7000-7999Reserved
    8000-8999User De?ned3
    9000-9999Misc Elective Notes4
  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章           查看所有文章
加:2021-08-03 17:19:59  更:2021-08-03 17:20:25 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/9 18:40:24-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码