源码格式化工具Astyle及编辑器集成

来源:互联网 发布:win8未激活网络怎么办 编辑:程序博客网 时间:2024/06/03 12:45

1.astyle是一个开源的源码格式化工具软件,命令行版的,官方网址:
  
Home Page: http://astyle.sourceforge.net/ 
Project Page: http://sourceforge.net/projects/astyle/ 

2.使用方法
  因为只有一个exe就可以执行,为了使用方便,我把它拷贝到windows/system32目录下。
  运行cmd.exe,进入命令行
  astyle -h   得到命令行帮助,参数有很多,不过如果大多数情况下并不使用,默认设置就很好了

  astyle a.c    格式化当前目录下的a.c文件
  astyle *.c    格式化所有当前目录下的.c 文件

  可以把你的喜欢的风格存为一个文本文件,名必须为 astylerc ,存放在%USERPROFILE%目录下,以后就不用输入参数了,

我的astylerc 文件内容为

style=ansi
#---------------indent options-----------------
indent=spaces=4
indent-preprocessor
indent-namespaces
max-instatement-indent=80
min-conditional-indent=0
pad=oper
unpad=paren
#------------- breack options --------------------
one-line=keep-statements
one-line=keep-blocks

#Add extra indentation to namespace blocks
suffix=none
errors-to-stdout
3.编辑器集成
---------------------------------------------------------
  1)   Program notepad 

 


---------------------------------------------------------
  2)   IAR 4.21

 


----------------------------------------------------------
  3)   Visual C++ 6.0 

 



  4)   AVR Studio (帮助中没有打开配置工具的参数,没有完成)



  5) IAR 7.13