我刚开始使用Astyle和VS-2013 for C ++。我想将其配置为遵循Google C++ style guide。我注意到Astyle允许导入配置文件,所以我想知道是否有人完成了艰苦的工作并将其配置为遵循Google C ++风格指南?如果没有,那么我应该在“设置”窗口中进行哪些调整:
有什么想法吗?
答案 0 :(得分:1)
首先,我认为AStyle的功能不足以让您的代码完全遵循谷歌C ++风格指南。例如,以下代码段(Function Calls中的示例)无法通过AStyle获取,而是通过手动对齐获得。
DoSomething(
argument1, // 4 space indent
argument2,
argument3,
argument4);
此外,我不认为推荐行参数--style=google / -A14
与风格指南一致
我自己的选项文件如下:
# 2 space indent
-s2
# Indent 'class' and 'struct' access modifiers, 'public:', 'protected:' and 'private:', one half indent.
-xG
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. The entire case block is indented.
-S
# Do not retain a backup of the original file. The original file is purged after it is formatted.
#-n
# Don't break one-line blocks.
-O
# Don't break complex statements and multiple statements residing on a single line.
-o
# Attach a pointer or reference operator (*, &, or ^) to the variable name (right).
-k3
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
-H
# Insert space padding around operators.
-p
恕我直言,AStyle将帮助您大量转换代码,但有些细节只能手动转换。