gpt4 book ai didi

c++ - Google C++ 风格指南的 AStyle

转载 作者:太空宇宙 更新时间:2023-11-04 11:33:31 26 4
gpt4 key购买 nike

我刚开始使用 Astyle 和 VS-2013 for C++。我想将其配置为遵循 Google C++ style guide .我注意到 Astyle 允许导入配置文件,所以我想知道是否有人完成了艰苦的工作并将其配置为遵循 Google C++ 风格指南?如果不是,那么我应该在设置窗口中进行哪些调整:

enter image description here

有什么想法吗?

最佳答案

首先,我认为 AStyle 不够强大,无法让您的代码完全遵循 google 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 会帮助您进行大范围的代码转换,但有些细节只能手动转换。

关于c++ - Google C++ 风格指南的 AStyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23684451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com