LXR | KVM | PM | Time | Interrupt | Systems Performance | Bootup Optimization

SourceInsight工具增强——AStyle(代码格式化)、PC-Lint(静态检查)

Artistic Style(AStyle)

AStyle是一款开源、高效、精简的代码格式化工具,适用于C、C++、C#、Java等。官方地址在:http://astyle.sourceforge.net/

AStyle支持Linux、Mac或者Windows,Windows下有预编译的exe文件,其他平台需要自己编译。

输入AStyle -h可以后去AStyle的详细使用介绍:

                     Artistic Style 3.0
                     Maintained by: Jim Pattee
                     Original Author: Tal Davidson

Usage:
------
            astyle [OPTIONS] File1 File2 File3 [...]

            astyle [OPTIONS] < Original > Beautified

将AStyle集成到SourceInsight,可以极大提高工作效率。

SourceInsight->Options->Custom Commands,设置如下:

image

Run部分如下:AStyle.exe  --style=linux  --mode=c -p -U  --suffix=none  %f

指定格式化风格为linux.

--mode=c 处理C/C++源文件

-p 在操作符两边插入空格,如=、+、-等。

-d 在括号外面插入空格。

-U移除括号两边不必要的空格。

none不备份文件,%f表示当前文件

PC-Lint

安装PC-Lint之后。

SourceInsight->Options->Custom Commands,设置如下:

image

如果在执行PC-Lint过程中出现头文件找不到情况,打开pc-lint安装目录下std.lnt文件,在文件尾以”-I ”方式加上所需的头文件所在的路径,如:-I C:/ISIPPC/diab/4.2b/include -IC:/Tornado/host/diab/include。

添加菜单或者快捷键

在设置好AStyle和PC-Lint两个命令之后,可以将其加入菜单中。或者进入Keys…设置快捷键。

image

posted on 2017-04-07 17:35  ArnoldLu  阅读(2053)  评论(0编辑  收藏  举报

导航