我有旧的C代码,想用clang格式重新格式化。面临的一个问题是,许多旧函数是用K&R参数初始化程序列表编写的。 而clang-format在这些行上进行了奇怪的重新格式化。
示例:
int tz_start_new( nr, start, old )
char *nr;
char *start;
char *old;
{
return 0;
}
获取格式化为:
int tz_start_new( nr, start, old ) char *nr;
char *start;
char *old;
{
return 0;
}
因此,第一个参数直接写在函数声明的后面。 其他人则像以前一样呆着。
这是我正在使用的格式文件:
---
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeTernaryOperators: 'false'
IndentCaseLabels: 'true'
ColumnLimit: '80'
IndentWidth: '4'
Language: Cpp
PointerAlignment: Right
SortIncludes: 'false'
SpaceAfterCStyleCast: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: Never
SpaceInEmptyParentheses: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'true'
SpacesInSquareBrackets: 'true'
TabWidth: '4'
UseTab: ForIndentation
...
那么我如何才能像以前一样将所有参数都保留在函数声明下?