使用Astyle格式化代碼


在github中clone了nanomsghttps://github.com/davidmpc/nanomsg.git的源代碼,發現代碼是google風格,即for、if后大括號沒有另起一行,十分不習慣,因此需要改變代碼格式。

參考http://blog.csdn.net/i_am_tom/article/details/54375266,在sourceforgehttps://sourceforge.net/projects/astyle/?source=typ_redirect中下載了macos的Astyle的代碼,進入build文件夾。

davidma@mac:~/software/astyle$ls

LICENSE.md README.md  build      doc        file       src

直接make,在bin中有Astyle的可執行文件。

執行如下命令,既可以讓大括號另起一行、switch中case前有一個tab、對文件夾下所有的.c迭代格式化。

davidma@mac:~/software/astyle/build/mac/bin$./AStyle --style=allman --indent-switches --recursive ../../../../../Documents/code/nanomsg/nanomsg/src/*.c

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM