clang-format 有 2 个选项,称为BinPackParameters
和
BinPackArguments
。它们似乎控制函数声明和函数调用的缩进方式。
BinPackParameters
似乎为函数声明提供了预期的结果,但BinPackArguments
似乎不像人们对函数调用所期望的那样工作。
这是一个简单的测试文件:
#include <stdbool.h>
void function_with_a_huge_name_that_should_just_not_be(unsigned int a, char *b, unsigned int c, unsigned int d, unsigned int e)
{
return;
}
int main()
{
function_with_a_huge_name_that_should_just_not_be(13, "bb", 1234234, 4324324, 2355345);
}
这就是它的格式:
#include <stdbool.h>
void function_with_a_huge_name_that_should_just_not_be(unsigned int a,
char *b,
unsigned int c,
unsigned int d,
unsigned int e)
{
return;
}
int main()
{
function_with_a_huge_name_that_should_just_not_be(
13, "bb", 1234234, 4324324, 2355345);
}
我的.clang-format
文件如下:
---
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackParameters: false
BinPackArguments: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
我的 clang 格式版本是:3.6.0 (tags/RELEASE_360/final)
如果两者都BinPackParameters
为BinPackArguments
假,我会期望函数调用的缩进与函数声明的缩进相同。
知道我做错了什么吗?