artistic astyle 2.06,格式化keil代码(rt-thread)

astyle代码格式化工具可用在keil当中,自动化格式化编码风格,使用非常方便。

RT-thread有编码风格要求,且提供了astyle自动化代码格式参数。

在keil中使用astyle的步骤如下:

1、下载astyle,V2.06测试可用,下载链接:https://download.csdn.net/download/shangduqiuhun/10548789

2、把bin目录下的Astyle.exe拷贝到keil安装目录下的Eclipse目录下;

3、在keil的Tools菜单项,单击Customize Tools Menu...

4、按照下图步骤1和2建立两个菜单项:Astyle Current File(格式化当前文件)和Astyle ALL  File(格式化当前文件所在目录的所有文件)。步骤3选择Astyle.exe,我的keil安装在d盘的keil474。步骤4按照RT-thread的编码风格设置。!E代表当前文件,"$E*.c" "$E*.h"代表当前文件所在目录下的所有.c、.h文件。

Astyle Current File的Argtments:!E --style=allman --indent=spaces=4 --indent-preproc-block --pad-oper --pad-header --unpad-paren --suffix=none --align-pointer=name --lineend=linux --convert-tabs --verbose

Astyle ALL  File的Argtments:"$E*.c" "$E*.h" --style=allman --indent=spaces=4 --indent-preproc-block --pad-oper --pad-header --unpad-paren --suffix=none --align-pointer=name --lineend=linux --convert-tabs --verbose

5、单击OK按钮,再次单击Tools菜单,会多出两个选项

6、打开一个.c文件,点击Astyle Current File,在build output窗口即可看到格式化结果,如果文件格式不一致就会有响应改变。

注:文件格式化前先保存一下。

猜你喜欢

转载自blog.csdn.net/shangduqiuhun/article/details/81098346