I just started using Astyle with VS-2013 for C++. I want to configure it to follow the Google C++ style guide. I noticed that Astyle allows configuration files to be imported, so I was wondering has somebody done the hard work and configured it to follow the Google C++ style guide? If not, then what adjustments should I make in the Settings window:
Any ideas?
In the first place, I don't think AStyle is powerful enough to let your code totally follow the google C++ style guide. For example, the following code segment, which is an example in Function Calls, cannot be obtained by AStyle, but by manual alignment.
DoSomething(
argument1, // 4 space indent
argument2,
argument3,
argument4);
Besides, I don't think the commend line argument --style=google / -A14
aligns well with the style guide.
My own option file is as follow:
# 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
IMHO, AStyle will help convert your code in large, but some details can only be converted manually.