栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

c++源码工具

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

c++源码工具

c++/c源代码查看辅助工具

unifdef

https://docs.oracle.com/cd/E75432_01/html/E71066/unifdef-1.html

  • 解析删除C程序源中经过ifdef的行,非系统自带要安装

  • 命令格式:unifdef [-clt] [-Dname] [-Uname] [-iDname] [-iUname] … [filename]

    • –c 正常操作补充。将被删除或留空的行会得到保留,反之亦然
    • –l 使用空白行代替删除的行
    • –t 纯文本选项。unifdef禁止尝试识别注释、单引号和双引号
    • –Dname 与定义符号name相关联的行(行为类似#define name为true)
    • –Uname 与未定义符号name相关联的行(行为类似#define name为false)
    • –iDname 忽略但输出与定义符号name相关联的行。如果要使用ifdef来分隔非C行,如构建中的注释或代码,那么必须为指明将用于该目的的符号,使其不会解析其中的引号和注释
    • –iUname 忽略但输出与未定义符号name相关联的行
  • 不能识别编译器预制宏定义(例如__linux__),全靠用户自己指定宏是否定义

stripcc

http://stripcc.sourceforge.net/stripcc_cn.html

  • 非系统自带,需要源码安装
  • stripcc工作原理
  • 在要处理的代码(比如*.c/*.h)中合适的位置插入gcc扩展的预编译头#warning
  • 进而编译整个项目获取gcc编译输出并进行分析
  • 根据分析结果确定某段代码是否使用,使用则保留,未使用则去除
  • 命令选项:
    • -c 用来指定项目编译使用的命令,默认是“make”,如果您的项目也是“make”编译,则可略过“-c”选项,如果是其他,比如“make vmlinux”则需要指定“ -c “make vmlinux”
    • -m 用来指定执行编译命令(如“make”)的目录,这对一些不是在顶层目录执行编译命令的项目非常有用
    • -n 让stripcc在处理完代码之后直接退出,而不执行验证过程,用户可以手动敲入“make”等项目编译命令自行验证
  • demo以googletest-release-1.5.0为例
    • 在googletest-release-1.5.0make目录下,运行make
    • 返回googletest-release-1.5.0目录运行stripcc -m “make”
// googletest-release-1.5.0srcgtest-internal-inl.h处理前片段
#if !GTEST_IMPLEMENTATION_
// A user is trying to include this from his code - just say no.
#error "gtest-internal-inl.h is part of Google Test's internal implementation."
#error "It must not be included except by Google Test itself."
#endif  // GTEST_IMPLEMENTATION_

#ifndef _WIN32_WCE
#include 
#endif  // !_WIN32_WCE
#include 
#include   // For strtoll/_strtoul64/malloc/free.
#include   // For memmove.

#include 
#include 
#include 

#include 

#if GTEST_OS_WINDOWS
#include   // For DWORD.
#endif  // GTEST_OS_WINDOWS

#include   // NOLINT
#include 

// googletest-release-1.5.0srcgtest-internal-inl.h处理后对应片段
#include 
#include 
#include   // For strtoll/_strtoul64/malloc/free.
#include   // For memmove.

#include 
#include 
#include 

#include 


#include   // NOLINT
#include 
cppinsights
  • 去掉语法糖,展示编译器实际代码
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/429804.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号