astyle、clang-formta代码格式化工具

astyle

https://astyle.sourceforge.net/

一篇比较好的中文介绍
https://blog.csdn.net/weixin_39950873/article/details/131635456

总结的一套配置

style_format:
	@find (dir) \
		-name "*.c" -o -name "*.h" | \
	xargs astyle --style=kr \
		--indent=spaces=4 \
		--indent-switches \
		--indent-after-parens \
		--indent-preproc-define \
		--indent-col1-comments \
		--attach-closing-while \
		--attach-return-type \
		--pad-oper \
		--pad-header \
		--unpad-paren \
		--delete-empty-lines \
		--squeeze-lines=2 \
		--squeeze-ws \
		--add-braces \
		--align-pointer=name \
		--align-reference=name \
		--convert-tabs \
		--lineend=linux \
		--suffix=none

clang-format

官方配置选项解释 https://clang.llvm.org/docs/ClangFormatStyleOptions.html
kernel clang-format介绍 https://www.kernel.org/doc/html/next/process/clang-format.html
一篇比较好的中文总结 https://zhuanlan.zhihu.com/p/641846308

posted @ 2023-11-06 14:33  zephyr~  阅读(68)  评论(0编辑  收藏  举报